Java Programming Questions & Answers: part8



Software Programming : Java Programming QUESTIONS AND ANSWERS :: part8 : 6 to 10

Following Software Programming language Entrance Multiple choice objective type questions and answers will help you in Software Programming 2024 examinations :

6.Which of the following statements is true?

Non-static member classes must have either default or public accessibility
All nested classes can declare static member classes
Methods in all nested classes can be declared static
All nested classes can be declared static
Static member classes can contain non-static methods.

7.Which statement is true?

Objects can be explicitly destroyed using the keyword delete
An object will be garbage collected immediately after it becomes unreachable
If object obj1 is accessible from object obj2, and object obj2 is accessible from obj1, then obj1 and obj2 are not eligible for garbage collection
Once an object has become eligible for garbage collection, it will remain eligible until it is destroyed
If object obj1 can access object obj2 that is eligible for garbage collection, then obj1 is also eligible for garbage collection.

8.Which is the first line that will cause compilation to fail in the following program? class MyClass { public static void main(String[] args) { MyClass a; MySubclass b; a = new MyClass(); //(1) b = new MySubclass(); //(2) a = b; //(3) b = a; //(4) a = new MySubclass(); //(5) } } class MySubclass extends MyClass {}

Line labeled (1)
Line labeled (2)
Line labeled (3)
Line labeled (4)
Line labeled (5).

9.Which of the following statements is true?

Inheritance defines a has-a relationship between a superclass and its subclasses
Every java object has a public method named equals
Every java object has a public method named length
A class can extend any number of other classes
All of the above.

10.Given three classes A,B,C, where B is a subclass of A and C is a subclass of B, which one of these Boolean expressions is true when an object denoted by reference has actually been instantiated from class B as opposed to from A or C?

(o instanceof B) && (!(o instanceof A))
(o instanceof B) && (!(o instanceof C))
!((o instanceof A) || (o instanceof B))
(o instanceof B)
(o instanceof B) && !((o instanceof A) || (o instanceof C)).

More Java Programming QUESTIONS AND ANSWERS available in next pages

    Health is the greatest gift, contentment is the greatest wealth -Buddha
If you are not willing to risk the usual you will have to settle for the ordinary- Jim Rohn