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

Question 5 (1 point) A reference variable of an interface type can be used to ac

ID: 3877345 • Letter: Q

Question

Question 5 (1 point) A reference variable of an interface type can be used to access any method specified in the interface. It can not be used to access any other method defined by the class of the object it refers to. O True O False Save Question 6 (1 point) Given a base class reference (bref) to a derived class object, and given that the derived class overrides methodX of the base class, when the following code executes: bref.methodxO; the base class version of methodX will run. True False Save

Explanation / Answer

Question 3

Answer : all of these are the differences between interfaces and abstract class

1.An interface should be implemented by class and abstract class is a class so we use extends keyword.

2.In interface the member variables cannot be specified whereas abstract class can have member values and they can be specified.

3.An interface cannot implement any methods on its own it only implements the methods when a class implements the interface. An abstract class can have abstract method and other methods so it can have some methods implemented.

Question 5

Answer : True

A reference variable can be declared as a class type or an interface type.If the variable is declared as an interface type, it can reference any object of any class that implements the interface. A reference variable of an interface type can be used to access any method specified in the interface but if we want to access any other methods defined in the class then we should declare the method in the interface.

Question 6

Answer: False

Base bref=new Derived();

Eventhough the object is of base class reference, bref.methodX(); the derived class version of methodX will run.

Since it refers to the subclass object and subclass method overrides the Parent class method, subclass method is invoked at runtime.

Question 10

Answer : True

When we test a class that is able to throw exceptions the program needs to contain the test cases to verify whether the exception is thrown whenever we expect it to occur. Because exceptions can be tested. And to test we provide testcases so that the expected exception can occur.

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