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

JAVA hw. All Ideas and ansewers are welcomed! thank you! 1.All objects inherit t

ID: 3835324 • Letter: J

Question

JAVA hw. All Ideas and ansewers are welcomed! thank you!

1.All objects inherit the methods from the Object class.

Select one:

True

False

2.In a child class, you can directly access private instance variables declared in the parent class.

Select one:

True

False

3.In a child class, you can directly invoke private methods declared in the parent class.

Select one:

True

False

4.In a child class constructor, if you do not explicitly call a parent constructor, then no parent constructor is ever called.

Select one:

True

False

5.Which of the following is the syntax to invoke the parent's constructor?

Select one:

super followed by dot

super followed by dot and the superclass constructor name

none of the above

super followed by parentheses containing arguments

6.When you overload a method, the type, order, and number of parameters must exactly match the original method.

Select one:

True

False

7.When you override a method, the type, order, and number of parameters must exactly match the original method.

Select one:

True

False

8.The equals method inherited from Object determines:

Select one:

whether two references have the same type.

whether two objects have the same instance variables.

whether two references refer to the same object in memory.

whether two objects have the same instance variable values.

9.Declaring a method final means that

Select one:

it cannot be accessed from outside its class.

it cannot be overridden.

it cannot be overloaded.

it cannot be accessed through an invoking object.

10.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 is true? Select all that apply.

Select one or more:

After the constructor for class B executes, b will have the value 8.

After the constructor for class B executes, the variable a will have the value 7.

b is an instance variable.

a is an instance variable

A reference of type B can be treated as a reference of type A. (B is an A)

A reference of type B has two integer characteristics as its instance data.

A reference of type A can be treated as a reference of type B. (A is a B)

Explanation / Answer

1. True

All objects inherit the methods from the Object class.

2. False

Inorder to inherit the properties from the parent class, we need to use a key word super else which is not possible for this criteria.

3. True

4. False

Automatically the default construcor of base class is called.

5. Option D

super followed by parentheses containing arguments.

6. False

In case of method overloading, method with same name co-exists in same class but they must have different method signature, while in case of method overriding, method with same name is declared in derived class or sub class.

7. True

9. Option B

it cannot be overridden.

10. Option B

A reference of type A can be treated as a reference of type B. (A is a B)