Java Basic

Quiz Guidelines

 

Multiple Choice Question

QID: 
77

Which of the following keywords may occur multiple times in a Java source file?

Select 4 options

A. import
B. class
C. private
D. package
E. public

Descriptive Question

QID: 
76

Identify valid modifiers for a top level class and method declarations.

(Assume that the class is not declared in another class)

Multiple Choice Question

QID: 
75

Which of the following are keywords in Java?

Select 4 options

A. default
B. NULL
C. String
D. throws
E. long
F. strictfp

Multiple Choice Question

QID: 
74

What is meant by "encapsulation"?

Select 1 option

A. There is no way to access member variable.
B. There are no member variables.
C. Member fields are declared private but public accessor/mutator methods are provided to access and change their values.
D. Data fields are declared public and accessor methods are provided to access and change their values.
E. None of the above.

Multiple Choice Question

QID: 
73

Consider the following two classes defined in two java source files.

//in file /root/com/foo/X.java

package com.foo;
public class X{
public static int LOGICID = 10;
public void apply(int i){
System.out.println("applied");
}
}

//in file /root/com/bar/Y.java

package com.bar;      //1 <== INSERT STATEMENT(s) HERE
public class Y{
public static void main(String[] args){
X x = new X();
x.apply(LOGICID);
}
}

What should be inserted at //1 so that Y.java can compile without any error?

Select 2 options

A. import static X;
B. import static com.foo.*;
C. import static com.foo.X.*;
D. import com.foo.*;
E. import com.foo.X.LOGICID;

Pages