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.

Consider the following code:
interface Area

  Method compute() in interface Area should be declared public

  Interface definition is incomplete

  All of these

  Method compute() in class Room should be declared public

  Half-n-half Clue
 

2.

Which of the following statements are true?
(A) An abstract class may not have any final methods.
(B) A final class may not have any abstract methods.
(C) An inner class may be declared with any accessibility keyword.
(D) Transient variables must be static
.

  (A)

  (B) & (C)

  (A) & (C)

  (D)

  Half-n-half Clue
 

3.

Which of the following defines a legal abstract class?

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

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

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

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

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

  Half-n-half Clue
 

4.

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 in all classes in the same package and subclasses in other packages.

  Visible only inside the package.

  Visible only in the class where it is declared.

  Half-n-half Clue
 

5.

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

  Result body is not fully defined.

  Student class is not available.

  Class result should be declared public.

  Test class is not available.

  Half-n-half Clue
 

6.

The concept of multiple inheritance is implemented in Java by
(A) extending two or more classes
(B) extending one class and implementing one or more interfaces
(C) implementing two or more interfaces
(D) all of these

  (A) & (C)

  (B) & (C)

  (A)

  (D)

  Half-n-half Clue
 

7.

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
 


 
12 more pages in Java Programming


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