Question 14)
Which of the following are valid methods?
1) public static native void amethod(){}
2) public static void ametic native void amethod(){}
3) private protected void amethod(){}
4) static native void amethod();
Answer to Question 14)
--------------------------------------------------------------------------------
Question 15)
Which of the following statements are true?
1) Constructors cannot have a visibility modifier
2) Constructors can be marked public and protected, but not private
3) Constructors can only have a primitive return type
4) Constructors are not inherited
Answer to Question 15)
--------------------------------------------------------------------------------
Question 16)
What will happen when you attempt to compile and run the following class?
class Base{
Base(int i){
System.out.println("Base");
}
}
class Severn extends Base{
public static void main(String argv[]){
Severn s = new Severn();
}
void Severn(){
System.out.println("Severn");
}
}
1) Compilation and output of the string "Severn" at runtime
2) Compile time error
3) Compilation and no output at runtime
4) Compilation and output of the string "Base"
Answer to Question 16)
--------------------------------------------------------------------------------
Question 17)
Which of the following statements are true?
1) static methods do not have access to the implicit variable called this
2) A static method may be called without creating an instance of its class
3) A static method may not be overriden to be non-static
4) A static method may not be overloaded
Answer to question 17)
--------------------------------------------------------------------------------
Question 18)
Which of the following will compile without error?
1)
char c='1';
System.out.println(c>>1);
2)
Integer i=Integer("1");
System.out.println(i>>1);
3)
int i=1;
System.out.println(i<<<1);
4)
int i=1;
System.out.println(i<<1);
Answer to Question 18)
--------------------------------------------------------------------------------
Question 19)
Which of the following are true?
1) A component may have only one event listener attached at a time
2) An event listener may be removed from a component
3) The ActionListener interface has no corresponding Adapter class
4) The processing of an event listener requires a try/catch block
Answer to Question 19)
--------------------------------------------------------------------------------
Question 20)
Which of the following are Java keywords?
1) sizeof
2) main
3) transient
4) volatile
Answer to Question 20)
--------------------------------------------------------------------------------
Question 21)
Which of the following statements are true?
1) The default constructor has a return type of void
2) The default constructor takes a parameter of void
3) The default constructor takes no parameters
4) The default constructor is not created if the class has any constructors of its own.
Answer to Question 21)