Syvum Home Page

Home > Quiz Games > Java Programming >

Java Programming : Compilation and Execution: Multiple Choice


Answer the following questions about Java syntax and mistakes which can cause compilation errors, as well as the output generated by sample programs.

Formats Info Page Worksheet / Test Paper Quiz Review
Multiple choice

Your Performance  

1.

The control expression in an "if" statement must be:

  an expression with type integer

  an expression with type boolean

  an expression with either the type boolean or integer

  an expression with either the type boolean or integer with value 0 or 1

  Half-n-half Clue
 

2.

Examine the following class definitions to detect errors, if any.
abstract class MyPanel

  1 Error. Method show() should have a return type

  1 Error. Method show() is not implemented in MyDisplay

  1 Error. MyDisplay does not contain any members

  No errors

  Half-n-half Clue
 

3.

Which of the following command lines options generates documentation for all classes and methods?

  -protected

  -encoding

  -verbose

  -private

  -public

  Half-n-half Clue
 

4.

For the following class definition, which is a legal statement to construct an object of type Class1:
class Class1 extends Class2

  (A)

  (C) & (E)

  (A) & (B)

  (C) & (D)

  None of the above

  Half-n-half Clue
 

5.

To print the value of a variable "x" of type int, which of the following expressions can be used:
(A) System.out.println("x = " + x);
(B) System.out.println("x = " + String.valueOf(x));
(C) System.out.println("x = " + Integer.toString(x));
(D) System.out.println("x = " + (new Integer(x)).toString());

  (B) and (D)

  (A), (B), (C) and (D)

  (C) and (D)

  (B), (C) and (D)

  Half-n-half Clue
 

6.

What will be the output of the following program?
class Main1

  Error. Won't compile

  YYY

  XXX followed by YYY

  XXX

  Half-n-half Clue
 

7.

With javadoc, which of the following denotes a javadoc comment?

  /**

  /*

  //**

  //#

  Half-n-half Clue
 


 
12 more pages in Java Programming


Contact Info © 1999-2025 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright
Previous
-
Next
-