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.

Which error does the following code contain: class Class1

  Class Class1 has not been declared public

  Method func1() must be declared as static

  Class1 should be declared as abstract

  There is no error

  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.

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
 

4.

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());

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

  (B) and (D)

  (C) and (D)

  (B), (C) and (D)

  Half-n-half Clue
 

5.

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
 

6.

What is java_g used for?

  None of these

  To provide information about deprecated methods

  Executing a class with optimization turned off

  Using the jdb tool

  Half-n-half Clue
 

7.

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

  @parameter

  @method

  @value

  @argument

  @param

  Half-n-half Clue
 


 
12 more pages in Java Programming


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