Quiz Guidelines


Multiple Choice Question


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

Assume that PrintWriter and OutputStreamWriter are valid classes in package. 

Select 1 option

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

Multiple Choice Question


Given the following contents of two java source files:

package util.log4j;
public class Logger {
public void log(String msg){


package util;
public class TestClass {
public static void main(String[] args) throws Exception {
Logger logger = new Logger();

What changes, when made independently, will enable the code to compile and run?

Select 2 options
A. Replace Logger logger = new Logger(); with:
         log4j.Logger logger = new log4j.Logger();
B. Replace package util.log4j; with
         package util;
C. Replace Logger logger = new Logger(); with:
          util.log4j.Logger logger = new util.log4j.Logger();
D. Remove package util.log4j; from Logger.
E. Add import log4j; to TestClass.

Multiple Choice Question


Which of the following are not legal Java identifiers?

Select 1 option

A. goto
B. unsigned
C. String
D. _xyz
E. $_abc
F. iLikeVeryVeryVeryVeryVeryLongIdentifiersThatDontMakeAnySenseAtAll (65 characters)

Multiple Choice Question


What will the following code print when run?

public class TestClass{
  public static long main(String[] args){
     return 10L;

Select 1 option

A. Hello
B. It will print nothing.
C. It will not compile
D. It will throw a Throwable at runtime.
E. None of the above.

Multiple Choice Question


Consider the following directory structure shown in Image 1 that displays available folders and classes and the code is given below.

class StockQuote{
Stock stock;
public StockQuote(Stock s) {
}public double computePrice(){
return Helper.getPricer(stock).price();
}  }

Assuming that the code uses valid method calls, what statements must be added to the above class?

Select 2 options

A. import com.enthu.*;
B. import com.*.*;
C. import *.*.*;
D. import com.*;
E. import com.enthu.rad.*;
F. import all;


Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!