Java Basic

Quiz Guidelines

 

Multiple Choice Question

QID: 
57

Which of the following lines can be inserted at line 1 to make the program run?

//line 1
public class TestClass{
public static void main(String[] args){
PrintWriter pw = new PrintWriter(System.out);
OutputStreamWriter osw = new OutputStreamWriter(System.out
);
pw.print("hello");
}
}

Assume that PrintWriter and OutputStreamWriter are valid classes in java.io package. 

Select 1 option

A. import java.lang.*;
B. import java.io.*;
C. import java.io.OutputStreamWriter;
D. include java.io.*;
E. include java.lang.System;

Multiple Choice Question

QID: 
56

Which of these statements concerning the use of modifiers are true?

Select 1 option

A. By default (i.e. no modifier) the member is only accessible to classes in the same package and subclasses of the class. 
B. You cannot specify visibility of local variables. 
C. Local variable always have default accessibility. 
D. Local variables can be declared as private. 
E. Local variables can only be declared as public.

Pages