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

In the java language, answer if the following are true or false. All methods and

ID: 669731 • Letter: I

Question

In the java language, answer if the following are true or false.

All methods and constructors of a parent class are inherited by the child class.

All instance varables in a parent class can be directly accessed in a child class.

A class can directly inherit from class Object.

A child class's instance variables are normally declared private to enforce good principles of software engineering.

Objects of the child class can be treated like objects of the parent class.

A parent class's instance variables are normally declared private to enforce good principles of software engineering.

------------

Consider the classes below, declared in the same package.

class A {

int a;

public A() {

a = 7;

}

}

class b extends A {

int b;

public B() {

b = 8;

}

}

Which of the following are true?

b is an instance variable

after the constructor for class b executes, the varibale will have the value 7

a is an instance variable

a reference of type a can be treated as a reference of type b

a reference of type b can be treated as a reference of type a

a reference of type b has two integer characteristics as its instance data

after the constructor for class b executes, b will have the value 8

Explanation / Answer

All methods and constructors of a parent class are inherited by the child class.
False


All instance varables in a parent class can be directly accessed in a child class.
False

A class can directly inherit from class Object.
False

A child class's instance variables are normally declared private to enforce good principles of software engineering.
False

Objects of the child class can be treated like objects of the parent class.
True

A parent class's instance variables are normally declared private to enforce good principles of software engineering.
False

b is an instance variable
False b is data member

after the constructor for class b executes, the varibale will have the value 7
b = 8, a = 7

a is an instance variable
False a is data member

a reference of type a can be treated as a reference of type b
No

a reference of type b can be treated as a reference of type a
Yes

a reference of type b has two integer characteristics as its instance data
yes

after the constructor for class b executes, b will have the value 8
Yes

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote