Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class A defines a method called clear(). Class B, extends class A and provides a method clear() (it has the same prototype as the one

Class A defines a method called clear(). Class B, extends class A

and provides a method clear() (it has the same prototype as the one in class A).

Which clear() method will be called in the following code fragment if we assume

early/static binding is being used? You can assume A and B have default

constructors.

A obj = new B();

obj.clear();

a. The clear() method of class A.

b. The clear() method of class B.

c. The clear() method in the Object class.

d. None of the above.

Class A is an abstract class with a single abstract method called analyze().

Class B extends class A, only defines a single non-abstract method called task(),

and does not provide an implementation for analyze(). Which of the following

are true?

a. Class B will compile whether it is defined abstract or not.

b. Class B must be defined abstract, otherwise the code will not compile.

c. We can create instances of B, but not of A.

d. None of the above.

The average(int x) method in a class called "Tools" performs a special

average computation. We would like classes extending the "Tools" class

to use the method, but not to change the computation the method does.

How should the average method be defined in order to provide this guarantee?

a. The method should be defined as protected.

b. The method should be defined as static.

c. The method should be defined as final.

d. None of the above.

The method sum() is called in the linearize() method. If sum() can throw

a checked exception, then:

public void linearize() {

sum();

}

a. The above linearize() method will compile.

b. The above linearize() method will not compile.

c. None of the above.

A set of tests generate 90% test coverage for a piece of code. This means that:

a. 90% of the code has no bugs and 10% has bugs.

b. 90% of the code has no bugs and 10% may or may not have bugs.

c. 90% of the code has bugs and 10% has no bugs.

d. None of the above.

In the expression a.separate(b), a and b are reference variables

of the same type. Inside of the separate method, which object

is associated with the current object reference ("this")?

a. The same object associated with a.

b. The same object associated with b.

c. There is no object associated with "this".

d. None of the above.

A Car class does not define an equals method (one that returns a

boolean and has an Object reference parameter). If a and b are Car

references, a.equals(b) is equivalent to:

a. a == b

b. a != b

c. a < b

d. None of the above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago