|
|
 |
javaprepare.com
your tool for Java Certification
|
home | tutorial | questions | test 1
Questions on Classes
- What gets displayed on the screen when the following program is
compiled and run. Select the one correct answer.
protected class example {
public static void main(String args[]) {
String test = "abc";
test = test + test;
System.out.println(test);
}
}
- The class does not compile because the top level class cannot be
protected.
- The program prints "abc"
- The program prints "abcabc"
- The program does not compile because statement "test = test +
test" is illegal.
- A top level class may have only the following access modifier.
Select one correct answer.
- package
- friendly
- private
- protected
- public
- 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.
- Select the one most appropriate answer. A top level class without
any modifier is accessible to -
- any class
- any class within the same package
- any class within the same file
- any subclass of this class.
- Is this True or False. In Java an abstract class cannot be
sub-classed.
- Is this True or False. In Java a final class must be sub-classed
before it can be used.
- Which of the following are true. Select all correct answers.
- A static method may be invoked before even a single instance of
the class is constructed.
- A static method cannot access non-static methods of the class.
- Abstract modifier can appear before a class or a method but not
before a variable.
- final modifier can appear before a class or a variable but not
before a method.
- Synchronized modifier may appear before a method or a variable but
not before a class.
Answers to questions on classes
in Java
- a
- e
- protected
- b
- False
- False
- a, b, c. final modifier may appear before a method, a variable or
before a class.
home | tutorial | questions | test 1
|