Order the following by when they are initialized:
2, 3, 1
- Among themselves the order is the order in which they appear in the code.
Which method declarations will enable a class to be run as a standalone program:
4, 5
True/false:
True
- You can however suggest the JVM to perform garbage collection by calling System.gc();
Which of these statements concerning the use of modifiers are true:
2
True/false:
You cannot apply any modifier except final
True.
- i.e. you cannot make them transient, volatile, static, public, and private.
True/false:
A method that has a body can be abstract.
False.
- an abstract method cannot have a body.
The following is a valid member variable declaration: private static final transient int i = 20;
True.
- You can apply all the modifiers to member variables except abstract, native and synchronized.
True/false: The following import statement is valid:
static import java.lang.System.*;
False
- The order of static and import is invalid. It should have been “import static”.
True/false: It is not required to import java.io.* or import java.io.IOException because java.io package is imported automatically.
False.
- Only java.lang package is imported automatically.
What does the zeroth element of the string array passed to the standard main method contain:
4.
- If no argument is passed the args parameter is NOT null but a valid non-null String array of length zero.
An instance member …
1, 4 - An instance member belongs to a single instance, not the class as a whole. An instance member is a member variable or a member method that belongs to a specific object instance. All non-static members are instance members.
True/false:
Syntax for importing static fields is: import static ..*;
or import static ..;
True.
How can you declare a method someMethod() such that an instance of the class is not needed to access it and all the members of the same package have access to it:
1, 2, 3
- must be static