FOR0283 Programming II: Homework Test 2 (Multiple-choice)

Instructions: e-mail your answers to the class lecturer.
Use subject header "FOR0283 multi 2".

1

1. An example of a superclass, class, subclass is:

a) House,Room,Garage

b) Reptile, Bird, Mammal

c) Building, Level, Apartment

d) Animal, Bird, Parrot

e) Animal, Horse, Cat

2. Which statement is true?

a) Every class has a superclass.

b) Every class has a subclass.

c) Every class other than Object has a superclass.

d) Every class other than Object has a subclass.

e) Every class is a concrete class.

3. When using method overloading what is most true about the methods involved?

a) they have the same name

b) they have different parameter lists

c) they have the same return type

d) A, B and C above

e) none of the above


4. If an object of B is created, what is output given the definition of B as:

class A {public A() {foo();}

public void foo( ) {

System.out.print("hello");}}

class B extends A{

public void foo( ) {super.foo();

System.out.print("goodbye");}}

a) hello

b) goodbyehello

c) hellogoodbye

d) goodbye

e) hellohello

5.  How many lines of text are output?

System.out.println(“1 big bad wolf\t8 the 3 little pigs\n4 dinner\r2night”);

a)  1

b)  2

c)  3

d)  4

e)  5

6. Which of the following outputs the text “hi there”, including the quote marks?

a)  System.out.println("hi there");

b)  System.out.println(""hi there"");

c)  System.out.println("\"hi there");

d)  System.out.println("\"hi there\"");

e)  none of the above

7. The advantages of the DecimalFormat class compared with the NumberFormat class include:

a) precise control over the number of digits to be displayed
b) control over the presence of a leading zero
c) the ability to truncate values rather than to round them
d) the ability to display a % automatically at the beginning
e) only (a) and (b)

8. Autoboxing is

a) the automatic conversion of a wrapper object to/from its corresponding primitive type
b) the automatic enclosure of a graphics object within a bounding box
c) the automatic widening of ints into floats or doubles, as required
d) the automatic conversion of an enumeration into its numeric representation
e) none of the above

A grade 8 is 78 - 82 %, grade 8,5 is 83-87%, grade 9,0 is 88 - 92 %, grade 9,5 is 93-97%, and grade 10 is 98 -100 %.

9) Which of the following set of values tests all the equivalent groups?
a) 81, 86, 87, 96,99
b) 78, 82, 83, 87, 88
c) 79, 84, 89, 94, 99
d) 80, 85, 90, 95, 101
e) 92, 93, 97, 98, 100

10) Which of the following set of values tests most boundaries?
a) 80, 85, 90, 95, 101
b) 80, 85, 90, 100, 101
c) 80, 85, 99, 100, 101
d) 77, 85, 99, 100, 101
e) 77, 79, 99, 100, 101

1