1. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
2.   
3.  protected class example {
4.    public static void main(String args[]) {
5.           String test = "abc";
6.           test = test + test;
7.           System.out.println(test);
8.    }
9.  }
10. 
    1. The class does not compile because the top level class cannot be protected.
    2. The program prints "abc"
    3. The program prints "abcabc"
    4. The program does not compile because statement "test = test + test" is illegal.
Answer-.A
02.  A top level class may have only the following access modifier. Select the one correct answer.
A.  package
B.     friendly
C.     private
D.    protected
E.     public
Answer-.E
03.  Write down the modifier of a method that makes the method available to all classes in the same package and to all the subclasses of this class.
Answer-.  protected
04.  Select the one most appropriate answer. A top level class without any modifier is accessible to -
A.    any class
B.     any class within the same package
C.     any class within the same file
D.    any subclass of this class.
Answer-.B
05.  Is this True or False. In Java an abstract class cannot be sub-classed.
Answer-.  False
06.  Is this True or False. In Java a final class must be sub-classed before it can be used.
Answer- . False
07.  Which of the following are true. Select the three correct answers.
A. A static method may be invoked before even a single instance of the class is constructed.
B.     A static method cannot access non-static methods of the class.
C.     Abstract modifier can appear before a class or a method but not before a variable.
D.    final modifier can appear before a class or a variable but not before a method.
E.     Synchronized modifier may appear before a method or a variable but not before a class.
Answer-.  A,B,C , final modifier may appear before a method, a variable or before a class.


0 comments:

Post a Comment

 
Top