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 method int func(int i, int j)

  (B) & (C)

  (C) & (D)

  (A), (B), (C) & (E)

  (A), (B) & (E)

  None of these

  Half-n-half Clue
 

2.

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)

  (B), (C) and (D)

  (C) and (D)

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

  Half-n-half Clue
 

3.

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

  an expression with either the type boolean or integer

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

  an expression with type boolean

  an expression with type integer

  Half-n-half Clue
 

4.

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

  -protected

  -encoding

  -verbose

  -private

  -public

  Half-n-half Clue
 

5.

Which javadoc tag is used to denote a comment for a method parameter?

  @value

  @method

  @param

  @argument

  @parameter

  Half-n-half Clue
 

6.

Determine the output when the value of x is zero:
if(x >= 0)
if(x > 0)
System.out.println("x is positive");
else
System.out.println("x is negative");

  None of these

  "x is positive"

  "x is negative"

  "x is positive" and "x is negative"

  Half-n-half Clue
 

7.

Consider the following code:
int i = 1;
switch(c)

  code is illegal and therefore will not compile

  output will be One

  output will be One, followed by Two, and then followed by Three

  output will be One followed by Two

  Half-n-half Clue
 


 
12 more pages in Java Programming


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