Q4.Which of the following are valid statements?
a) System.out.println(5+4);
b) int i=2+'3';
c) String s="one"+'Two';
d) byte b=255;
Q 5.Which of the following statements are true?
a) The garbage collection algorithm in Java is vendor implemented.
b) The size of primitives is platform dependent.
c) The default type for a numerical literal with decimal component is a float.
d) You can modify the value in an Instance of the Integer class with the setValue method.

Q6.Which of the following are true statements?
a) The creation of a named instance of the File class creates a matching file in the underlying operating system only when the close method is called.
b) The RandomAccessFile class allows you to move directly to any point a file.
c). I/O in Java can only be performed using the Listener classes.
d) The characteristics of an instance of the File class such as the directory separator, depend on the current underlying operating system.

Q 7.Which of the following statements are true?
a) The instanceof operator can be used to determine if a reference is an instance of a class, but not an interface.
b) The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class.
c) The instanceof operator will only determine if a reference is an instance of a class immediately above in the hierarchy but no further up the inheritance chain.
d) The instanceof operator can be used to determine if one reference is of the same class as another reference thus.

Q8.Which of the following statements are true?
a) An interface can only contain method and not variables.
b) Interfaces cannot have constructors.
c) A class may extend only one other class and implement only one interface.
d) Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementing classes to create the functionality of the Interfaces.

Q10.Which of the following are methods of the Runnable interface?
a) run
b) start
c) yield
d) stop
Q11.Which of the following statements are true?
a) A byte can represent between -128 to 127.
b) A byte can represent between -127 to 128.
c) A byte can represent between -256 to 256.
d) A char can represent between -2x2 pow 16 2 x2 pow 16 - 1.
Q12.What will happen when you attempt to compile and run the following code?
class Base{
public void Base(){
System.out.println("Base");
}
}
public class Inner extends Base{
public static void main(String argv[]){
Inner i=new Inner();
}
}
a) Compile time error Base is a keyword.
b) Compilation and no output at runtime.
c) Output of Base.
d) Runtime error Base has no valid constructor.
Q13.You have a public class called myclass with the main method defined as follows
public static void main(String parm[]) {

System.out.println(parm[0]);
}
If you attempt to compile the class and run the program as follows
“java myclass hello”
What will happen?
a) Compile time error, main is not correctly defined.
b) Run time error, main is not correctly defined.
c) Compilation and output of java.
d) Compilation and output of hello.

Q14.Which of the following statements are true?
a) If a class has any abstract methods it must be declared abstract itself.
b) All methods in an abstract class must be declared as abstract.
c) When applied to a class, the final modifier means it cannot be sub-classed.
d) transient and volatile are Java modifiers.
Q15.Which of the following are valid methods?
a) public static native void amethod(){}
b) public static void amethod(){}
c) private protected void amethod(){}
d) static native void amethod();

Q16.Which of the following statements are true?
a) Constructors cannot have a visibility modifier.
b) Constructors can be marked public and protected, but not private.
c) Constructors can only have a primitive return type.
d) Constructors are not inherited.

Q18.Which of the following statements are true?
a) A static methods do not have access to the implicit variable called this.
b) A static method may be called without creating an instance of its class.
c) A static method may not be overridden to be non-static.
d) A static method may not be overloaded.
Q19.Which of the following will compile without error?
a)char c='1';
System.out.println(c>>1);
b)Integer i=Integer("1");
System.out.println(i>>1);
c)int i=1;
System.out.println(i<<<1);
d)int i=1;
System.out.println(i<<1);

Q 20.Which of the following are Java keywords?
a) sizeof
b) main
c) transient
d) volatile
Q21.Which of the following statements are true?
a) The default constructor has a return type of void.
b) The default constructor takes a parameter of void.
c) The default constructor takes no parameters.
d) The default constructor is not created if the class has any constructors of its own.

Q22.Which of the following statements are true?
a) All of the variables in an interface are implicitly static.
b) All of the variables in an interface are implicitly final.
c) All of the methods in an interface are implicitly abstract.
d) A method in an interface can access class level variables.

Q 23.Which of the following statements are true?
a) The String class is implemented as a char array, elements are addressed using the stringname[] convention.
b) The + operator is overloaded for concatenation for the String class.
c) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper type.
d) The size of a string can be retrieved using the length property.

Q 24.Which of the following statements are true?
a) A method in an interface must not have a body.
b) A class may extend one other class plus at most one interface.
c) A class may extends at most one other class plus implement many interfaces.
d) An class accesses an interface via the keyword uses.
Q 25.Which of the following statements are true?
a) The following statement will produce a result of 1.
System.out.println( -1 >>>2);
b) Performing an unsigned left shift (<<
c) The following statement will produce a result of zero,
System.out.println(1 >>1);
d) All the Java integral types are signed numbers