Syvum Home Page

Home > Quiz Games > Java Programming >

Java Programming : Classes and Keywords: Multiple Choice


Answer the following questions about classes and reserved keywords as used in the Java programming language.

Formats Info Page Worksheet / Test Paper Quiz Review
Multiple choice

Your Performance  

1.

Which of the following defines a legal abstract class?

  abstract Vehicle {<br>
              abstract void display(); }

  class Vehicle {<br>
              abstract void display(); }

  abstract class Vehicle {<br>
              abstract void display(); }

  class abstract Vehicle {<br>
              abstract void display(); }

  abstract class Vehicle {<br>
              abstract void display(); {<br>
                System.out.println("Car"); }}

  Half-n-half Clue
 

2.

We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?

  private OR protected

  private

  protected

  public

  Half-n-half Clue
 

3.

The keywords reserved but not used in the initial version of Java are:
(A) union
(B) const
(C) inner
(D) goto
(E) boolean
(F) synchronized

  (B),(C) & (D)

  All of these.

  (A), (C) & (E)

  (C) & (E)

  Half-n-half Clue
 

4.

Package p1 contains the following code:
package p1;
public class Student

  Result body is not fully defined.

  Class result should be declared public.

  Test class is not available.

  Student class is not available.

  Half-n-half Clue
 

5.

Consider the following code:
interface Area

  All of these

  Method compute() in interface Area should be declared public

  Method compute() in class Room should be declared public

  Interface definition is incomplete

  Half-n-half Clue
 

6.

The use of protected keyword to a member in a class will restrict its visibility as follows:

  Visible only in the class and its subclass in the same package.

  Visible only in the class where it is declared.

  Visible only inside the package.

  Visible in all classes in the same package and subclasses in other packages.

  Half-n-half Clue
 

7.

Which of the following statements about abstract methods/classes in Java are true?
1. An abstract class cannot be instantiated.
2. Constructors cannot be abstract.
3. A subclass of an abstract class must defined the abstract methods.
4. Static methods may be declared abstract.

  Line 1, line 2 and line 3 only

  Line 1 only

  Line 1 and line 2 only

  Line 2 only

  All are true

  Half-n-half Clue
 


 
12 more pages in Java Programming


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