JavaQuizzes

Quiz Guidelines

 

Multiple Choice Question

QID: 
72

Which of the given options should be inserted at line 1 so that the following code can compile without any errors?

package objective1;       // 1
public class StaticImports{
public StaticImports(){
out.println(MAX_VALUE);
}
}

(Assume that java.lang.Integer has a static field named MAX_VALUE)

Select 2 options

A. import static java.lang.Integer.*;
B. static import java.lang.System.out;
C. static import Integer.MAX_VALUE;
D. import static java.lang.System.*;
E. static import java.lang.System.*;

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;

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: 
75

Which of the following are keywords in Java?

Select 4 options

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

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)

Pages