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 either the type boolean or integer with value 0 or 1

  an expression with type boolean

  an expression with either the type boolean or integer

  an expression with type integer

  Half-n-half Clue
 

2.

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

  XXX followed by YYY

  YYY

  Error. Won't compile

  XXX

  Half-n-half Clue
 

3.

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), (C) and (D)

  (B) and (D)

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

  (C) and (D)

  Half-n-half Clue
 

4.

Which of the following expressions will produce errors upon compilation?
(A) boolean a = (boolean) 1;
(B) boolean b = (false && true);
(C) float y = 22.3;

  (A)

  (A), (B) & (D)

  (A), (C) & (D)

  (A) & (C)

  Half-n-half Clue
 

5.

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
 

6.

Are there any errors in the following class definition?
abstract class Class1

  Class header definition is wrong

  Method definition is wrong

  Constructor needs to be defined

  No errors

  Half-n-half Clue
 

7.

What is java_g used for?

  Executing a class with optimization turned off

  None of these

  Using the jdb tool

  To provide information about deprecated methods

  Half-n-half Clue
 


 
12 more pages in Java Programming


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