image not found

Oops! That page can't be found.


Directions to Solve

In questions below, each passage consist of six sentences. The first and sixth sentence are given in the begining. The middle four sentences in each have been removed and jumbled up. These are labelled as P, Q, R and S. Find out the proper order for the four sentences.

Q1:
S1: A noise started above their heads.
P : But people did not take it seriously.
Q : That was to show everyone that there was something wrong
R : It was a dangerous thing to do.
S : For, within minutes the ship began to sink.
S6: Nearly 200 lives were lost on the fateful day.
The Proper sequence should be:

A PRQS

B PQSR

C QPSR

D QPRS

Q2: Point out the error in the program
#include<stdio.h>

int main()
{
    int a=10;
    void f();
    a = f();
    printf("%d\n", a);
    return 0;
}
void f()
{
    printf("Hi");
}

A Error: Doesn't print anything

B No error

C Error: Not allowed assignment

D None of above

Q3: What will be the output of the program?
package foo; 
import java.util.Vector; /* Line 2 */
private class MyVector extends Vector 
{
    int i = 1; /* Line 5 */
    public MyVector() 
    { 
        i = 2; 
    } 
} 
public class MyNewVector extends MyVector 
{
    public MyNewVector () 
    { 
        i = 4; /* Line 15 */
    } 
    public static void main (String args []) 
    { 
        MyVector v = new MyNewVector(); /* Line 19 */
    } 
}

A Compilation will fail at line 15.

B Compilation will fail at line 3.

C Compilation will fail at line 5.

D Compilation will succeed.

Q4: What will be the output of the program?
public class Test 
{ 
    private static int[] x; 
    public static void main(String[] args) 
    { 
        System.out.println(x[0]); 
    } 
}

A Compile Error

B NullPointerException at runtime

C null

D 0

Q5: What will be the output of the program?
import java.util.*; 
class I 
{
    public static void main (String[] args) 
    {
        Object i = new ArrayList().iterator(); 
        System.out.print((i instanceof List)+','); 
        System.out.print((i instanceof Iterator)+','); 
        System.out.print(i instanceof ListIterator); 
    } 
}

A Prints: false, true, false

B Prints: false, true, true

C Prints: false, false, false

D Prints: false, false, true

Q6: What will be the output of the program?
public class Test 
{ 
    private static float[] f = new float[2]; 
    public static void main (String[] args) 
    {
        System.out.println('f[0] = ' + f[0]); 
    } 
}

A Compile Error

B f[0] = 0.0

C Runtime Exception

D f[0] = 0

Q7: What will be the output of the program?
import java.util.*; 
class H 
{
    public static void main (String[] args) 
    { 
        Object x = new Vector().elements(); 
        System.out.print((x instanceof Enumeration)+','); 
        System.out.print((x instanceof Iterator)+','); 
        System.out.print(x instanceof ListIterator); 
    } 
}

A Prints: false,true,false

B Prints: false,false,true

C Prints: false,false,false

D Prints: true,false,false

Q8: What will be the output of the program?
TreeSet map = new TreeSet();
map.add('one');
map.add('two');
map.add('three');
map.add('four');
map.add('one');
Iterator it = map.iterator();
while (it.hasNext() ) 
{
    System.out.print( it.next() + ' ' );
}

A one two three four one

B four three two one

C one two three four

D four one three two

Q9: What will be the output of the program?
public static void main(String[] args) 
{
    Object obj = new Object() 
    {
        public int hashCode() 
        {
            return 42;
        }
    }; 
    System.out.println(obj.hashCode()); 
}

A Compile Error at line 2

B Compile Error at line 5

C 42

D Runtime Exception

Q10:
class Test1 
{
    public int value;
    public int hashCode() { return 42; }
}
class Test2 
{
    public int value;
    public int hashcode() { return (int)(value^5); }
}
which statement is true?

A class Test2 will not compile.

B
The Test1 hashCode() method is more efficient than the Test2 hashCode() method.

C The Test1 hashCode() method is more efficient than the Test2 hashCode() method.

D
The Test1 hashCode() method is more efficient than the Test2 hashCode() method.