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.

Examine the following code snippets to identify the legal loop constructs:
(A) for (int i = 22, int j = 0; i + j > 11; i = i-3, j++)

  (B)

  (A) & (C)

  (A)

  (A) & (D)

  Half-n-half Clue
 

2.

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
 

3.

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
 

4.

Consider the following code:
class NewString extends java.lang.String

  Results in error because java.lang.String isfinal

  Compiles successfully

  Results in error because the class is not declaredpublic

  Results in error because String isabstract

  Results in error because class body is not defined

  Half-n-half Clue
 

5.

What is java_g used for?

  None of these

  Using the jdb tool

  To provide information about deprecated methods

  Executing a class with optimization turned off

  Half-n-half Clue
 

6.

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), (B) & (D)

  (A) & (C)

  (A)

  (A), (C) & (D)

  Half-n-half Clue
 

7.

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
 


 
12 more pages in Java Programming


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