Questions attempted: 21/22
1 of 22

Question text

1Mark

Which of the following statements about constructors is NOT true?

Select one:
a.

A constructor initialises the state of the object.

b.

Other methods cannot be called from inside a constructor.

c.

Java will automatically create a default constructor if none is specified.

d.

A constructor has no return value type.

e.

Constructors can be overloaded.

2 of 22

Question text

1Mark

Assume we have four classes where NativeBird and DomesticBird are subclasses of Bird, and Budgerigar is a subclass of DomesticBird. Which of the following assignments is legal?


Select one:
a.
DomesticBird() b1 = new Bird();
b.

DomesticBird() b2 = new NativeBird();

c.

Bird() b3 = new Budgerigar();

d.

NativeBird() b4 = new DomesticBird();

e.

None of the other answers are legal

3 of 22

Question text

1Mark

Encapsulation is a process of:

Select one:
a.

Dividing a program into smaller parts to solve separately

b.

Focusing on the essential parts of the problem

c.

Grouping related items into one unit

d.

Hiding the internals of a class from the outside world

e.

Developing an interface for a class

4 of 22

Question text

1Mark

Which of the following is a post-test loop?

Select one:
a.

while

b.

do ... while

c.

for

d.

for each

e.

iterator

5 of 22

Question text

1Mark

Which of the following statements about software testing is true?

Select one:
a.

it is the process of searching for the source of errors

b.

it should be designed after the code has been written

c.

it is best conducted by the programmers who wrote the code

d.

it is necessary only at the implementation stage of development

e.

none of the above

6 of 22

Question text

1Mark

Which of the following is true of a class variable in Java?

Select one:
a.

A class variable is defined by the keyword 'final'

b.

It exists only when an object of the class has been created

c.

A copy of a class variable is created for each object created

d.

It can only be accessed by a class method

e.

None of the above

7 of 22

Question text

1Mark

Which of the following statements is NOT true in Java?

Select one:
a.

A method declared as private is only accessible within the same class.

b.

A field of an object exists while the object exists.

c.
The scope of a local variable is within the block in which it is defined, starting from the line it is defined.
d.
A local variable with the same name as a field will cause a compiler error.
e.

None of the above

8 of 22

Question text

1Mark

Which of the following is true of the keyword protected:

Select one:
a.

it cannot be applied to fields

b.

it is allocated by default to superclass methods

c.

it allows direct access from subclasses

d.

it provides more restrictive access than private

e.

none of the above

9 of 22

Question text

1Mark

Which of the following statements is correct regarding exception handling in Java?

Select one:
a.

An exception is an object representing details of a program failure

b.

A method can only throw one exception

c.

Each try block can only specify one catch statement

d.

A try block must include a finally clause

e.

Statements inside a catch block are run whether or not an exception occurs

10 of 22

Question text

1Mark
What is the name of the technique where a subclass declares a method with the same signature as in the superclass, but with a different method body?
Select one:
a.

abstraction

b.

modularisation

c.

overloading

d.

overriding

e.

none of the above

11 of 22

Question text

1Mark
To join a rock climbing group a person must be aged 12 or older, but less than 60. What values for age would you use to boundary test a method designed to check if a person was a suitable age to join this group?
Select one:
a.

11, 12, 59, 60

b.

11, 12, 60, 61

c.

12, 13, 59, 60

d.

12, 13, 60, 61

e.

None of the above

12 of 22

Question text

1Mark
Suppose you are working in a team developing a large software system. One of the programmers is implementing a Tourist class; the other programmers are writing classes that will use the Tourist class. Which of the following aspects of the public methods of the Tourist class do not need to be known by the programmers who are using the Tourist class?
Select one:
a.

The methods' names

b.

The methods' return types

c.

The methods' parameter types

d.

The code in the bodies of the methods

e.

What the methods do (i.e., their behaviour)