1.
Which access modifier have almost identical behaviour as that of default.?
A. 
B. 
C. 
D. 
Both public and protected
2.
Check the statements which are true.(Choose all that apply)
A. 
A member declared as ‘public’ CAN be accessed from ‘Other packages’.
B. 
A member declared with ‘protected’ access modifier CAN be accessed by the members of the ‘subclass’.
C. 
A member declared with ‘protected’ access modifier CANNOT be accessed by the members of the ‘Other package’.
D. 
A member declared with ‘Default’ access modifier CANNOT be accessed by the members of the ‘subclass’.
3.
State True are False.
Overriding does not depends on inheritance.
4.
Consider the following code:
class AT1 {
public static void main (String[] args)
{
byte[] a = new byte[1];
long[] b = new long[1];
float[] c = new float[1];
Object[] d = new Object[1];
System.out.print(a[0]+","+b[0]+","+c[0]+","+d[0]); } }
Which of the following will be the output of the above code?
A. 
B. 
C. 
D. 
Compile-time error
12
Consider the following code snippet: interface i1 { int i = 0; } interface i2 { int i = 0; } class inter implements i1, i2 { public static void main(String[] a) { System.out.println(i); } } Which of the following options will be the output of the above code snippet?
Answer:
a. Runtime
5.
The following class definitions are in separate files. Note that the Widget and BigWidget classes are in different packages:
package conglomo;
public class Widget extends Object{
private int myWidth;
XXXXXX void setWidth( int n )
{
myWidth = n;
}
}
// the following is in a separate file and in separate package
package conglomo.widgets;
import conglomo.Widget ;
public class BigWidget extends Widget {
BigWidget() {
setWidth( 204 ); }
}
Which of the following modifiers, used in line 4 instead of XXXXXX, would allow the BigWidget class to access the setWidth method (as in line 12)? (Choose 2)
A. 
B. 
Default (blank), that is, the method declaration would read void setWidth( int n )
C. 
D. 
E. 
6.
what do u mean by signatures in the function overloading?
A. 
B. 
C. 
D. 
7.
interface Base
{
boolean m1 ();
byte m2(short s);
}
which two code fragments will compile?
A. 
Abstract class Class2 implements Base {}
B. 
Abstract class Class2 extends Base
{ public boolean m1(){ return true; }}
C. 
Abstract class Class2 implements Base
{ public boolean m1(){ return (7 > 4); }}
D. 
Abstract class Class2 implements Base
{ protected boolean m1(){ return (5 > 7) }}
8.
public class Test { }
What is the prototype of the default constructor?
A. 
B. 
C. 
D. 
9.
Consider the code
publi class Animal
{
public void eat()
}
Which is the legal method override of Animal eat()
A. 
B. 
C. 
Public void eat() throws Exeption
D. 
10.
public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }
public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 10
}
}
Which of the following code fragments inserted, will allow to compile?
A. 
B. 
New Inner(); //At line 10
C. 
New ot.Inner(); //At line 10
D. 
New Outer.Inner(); //At line 10
11.
Given a method in a protected class, what access modifier do you use to restrict access to that method to only the other members of the same class?
A. 
B. 
C. 
D. 
12.
Class Animal
{
class Dog extends Animal
{
class DogTest
{
public static void main(String ar[])
{
Animal animal=new Animal();
Dog d=(Dog) animal;
}
}
What happen when the program is executed?
A. 
B. 
C. 
Throws NullPointerException
D. 
13.
State True or False
Abstract methods must be implemented by the concrete subclass, its also like concrete subclass overrides the abstract methods
14.
class A
{
protected int method1(int a, int b)
{
return 0;
}
}
Which is valid in a class that extends class A?
A. 
Public int method1(int a, int b) {return 0; }
B. 
Private int method1(int a, int b) { return 0; }
C. 
Public short method1(int a, int b) { return 0; }
D. 
Static protected int method1(int a, int b) { return 0; }
15.
Which of the following class level (nonlocal) variable declarations will not compile?
A. 
B. 
C. 
Private synchronized int e;
D. 
16.
public class Myfile
{
public static void main (String[] args)
{
String biz = args[1];
String baz = args[2];
String rip = args[3];
System.out.println("Arg is " + rip);
}
}
Select how you would start the program to cause it to print: Arg is 2
A. 
B. 
C. 
D. 
17.
Choose all that apply.
A. 
Overloaded methods must change the argument list
B. 
Overloaded methods can change the argument list
C. 
Overloaded methods can change the return type
D. 
Overloaded methods must change the return type
E. 
Overloaded methods can delare new or broader checked exceptions
18.
Public class foo
{
public void dostuff(int y,String s)
{}
}
class bar extends foo
{
public void dostuff(int y, long s)throws IOException
}
What is true about this?
A. 
Dostuff method is not overridden
B. 
Subclass bar overrides the dostuff() method
C. 
Dostuff method is not overloaded.
D. 
IOException an not be inserted in the overloading method.
19.
Abstract class Director
{
protected String name;
Director(String name)
{ this.name = name; }
abstract void occupation();
}
class FilmDirector extends Director
{ FilmDirector(String name)
{ super(name); }
void occupation()
{ System.out.println("Director " + name + " directs films");
}
}
public class TestDirector {
public static void main(String[] args)
{
FilmDirector fd = new FilmDirector("Manirathnam");
fd.occupation();
new Director("Manirathnam")
{ void occupation()
{
System.out.println("Director " + name + " also produces films");
} }
.occupation();
} }
Which of the following will be the output of the above code snippet?
A. 
Compilation fails at TestDirector class
B. 
Prints: Director Manirathnam also produces films
C. 
Prints: Director Manirathnam directs films
Director Manirathnam also produces films
D. 
Prints: Director Manirathnam directs films
20.
Which of the following modifier cannot be applied to the declaration of a field?
A. 
B. 
C. 
D. 
21.
Consider s1 and s2 are sets.
Which of the following options gives the exact meaning of the method call s1.retainAll(s2)?
A. 
A. transforms s1 into the union of s1 and s2
B. 
Transforms s1 into the intersection of s1 and s2.
C. 
Transforms s1 into the (asymmetric) set difference of s1 and s2
D. 
Copies elements from s2 to s1
22.
Class Test
{
Test(int i)
{
System.out.println("Test(" + i +")");
} }
public class Question{
static Test t1 = new Test(1);
Test t2 = new Test(2);
static Test t3 = new Test(3);
public static void main(String[] args){
Question Q = new Question(); } }
Which of the following options gives the correct order of initialization?
A. 
A. Test(3) Test(2) Test(1)
B. 
C. 
D. 
23.
Class TestString4
{
public static void main(String args[]) {
String s1 = "Its Great";
String s2 = "Its Tricky";
System.out.print(s1.concat(s2).length() + " ");
System.out.print(s1.concat(s2.substring(1, s1.length())).length()); } }
What will be the output of the following code snippet?
Answer:
A. 
B. 
C. 
D. 
24.
Which of the following options is true about multi-level inheritance?
A. 
Inheriting from two super classes
B. 
Inheriting from a class which is already in an inheritance hierarchy
C. 
Inheriting from more than one super class
D. 
Inheriting from a single class
25.
Anonymous class can have their own members.