Java Programming - Declarations and Access Control - Discussion

Discussion Forum : Declarations and Access Control - Pointing out the correct statements (Q.No. 5)
5.
class A 
{ 
    A( ) { } 
} 

class B extends A 
{ }
Which statement is true?
Class B'S constructor is public.
Class B'S constructor has no arguments.
Class B'S constructor includes a call to this( ).
None of these.
Answer: Option
Explanation:

Option B is correct. Class B inherits Class A's constructor which has no arguments.

Option A is wrong. Class B inherits Class A's constructor which uses default access.

Option C is wrong. There is just no implicit call to this( ).

Discussion:
11 comments Page 2 of 2.

Vandit said:   3 years ago
@All.

Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.


Post your comments here:

Your comments will be displayed after verification.