Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA 1) If class D is derived from class C, which is the sub-class and the super

ID: 3865658 • Letter: J

Question

JAVA

1)              If class D is derived from class C, which is the sub-class and the super class? Which class is the base class?

How do you stop a derived class from inheriting instance variables from a class you are designing?

Explain the difference between not declaring an access specifier and using the access specifier protected.

In a class declaration of a class B, how do you indicate that B is to be derived from class A?

How do you invoke a constructor of a base class from a direct sub-class?

What does overriding mean? When would you override a method?

Describe the difference between overriding and overloading.

What is meant by polymorphism in Java?

What are the public methods of the class Object? List all of them.

Explain what casting means when applied to reference variables and when it must be used.

Explain what the operator instanceof does.

What advantages does an abstract class offer? i.e., why would you create one?

What is the effect of declaring a method as final?   of declaring a class as final? A variable? A parameter?

14)          What is the difference between private and protected?   Be specific in terms of inheritance.

Explanation / Answer

If class D is derived from class C, which is the sub-class and the super class,Than class C is the base class

Generally speaking, private are accessible within the class, where it was defined. Protected are accessible within the 1st class where it was defined and within all classed, that are inherited from the 1st one. However both of the are accessible by the friend classes.

Protected Inheritance: When deriving from a protected base class, public and protected members of the base class become protected members of the derived class.


Private Inheritance: When deriving from a private base class, public and protected members of the base class become private members of the derived class.