Professional Documents
Culture Documents
RMIT Introduction To Information Technology Test Answers
RMIT Introduction To Information Technology Test Answers
A
A
C
C
may
may
may
may
use
use
use
use
all
all
all
all
public
public
public
public
methods
methods
methods
methods
of
of
of
of
class
class
class
class
A
B
B
A
Response was: D
Wrong Incorrect (0 mark)
A subclass instance may use superclass methods
Question 2 (1 mark) Attempt 1
Any instance of a Java class may use methods of the class
A
Object
B
String
C
Applet
D
Stack
Response was: A
Correct Correct (1 mark)
Question 3 (1 mark) Attempt 1
Which of the following pairs of classes could be expressed as a composition rela
tionship ?
A
Employee and Person
B
Project and Manager
C
Manager and Employee
D
Employee and Student
Response was: C
Wrong Incorrect (0 mark)
Composition refers to "has a" relationship
Question 4 (1 mark) Attempt 1
Assume that B is a subclass of A and that A has a constructor with 3 arguments.
Which of the following statements accurately represents a correct call to the su
perclass constructor as in (assuming that the required arguments are being passe
d correctly)?
A
this(...)
B
A(...)
C
super(...)
D
super.A(...)
Response was: D
Wrong Incorrect (0 mark)
Refer to section 7.2
Question 5 (1 mark) Attempt 1
What class relationship(s) ("is-a", "has-a") can be inferred from the class defi
nition below? (select all answers that apply)
public class A extends B
{
C c;
D d;
...
A
B
C
D
A
A
A
B
"is-a" B
"has-a" D
"has-a" C
"has-a" D
refA.d++
refA.c++
refA.a++
refA.b++
c
c
c
c
=
=
=
=
e2;
(Clerk) e1;
e1;
(Clerk)e2;
Response was: A
Wrong Incorrect (0 mark)
Superclass references can be cast to subclass reference using an explicit cast.
Unrelated class references cannot be cast nor converted.
Question 9 (1 mark) Attempt 1
Assume that CAccount and SAccount are subclasses of Account both of which have o
verridden the deposit() and withdraw() methods. Which of the statement below is
true regarding the transfer method?
public boolean transfer(Account from, Account to, double amount) {
if (from.withdraw(amount) == true) ) {
to.deposit(amount);
return true;
}
return false;
}
A
The actual method called cannot be determined at compile-time as
it depends on the type of objects being passed
B
It will always call the withdraw() and deposit() of Account clas
s
C
count
D
It will always call the withdraw() and deposit() of one of the s
ubclasses of Account
Response was: D
Wrong Incorrect (0 mark)
Due to dynamic binding the actual method called cannot be determined at compiletime
Question 10 (1 mark) Attempt 1
In the program below Super method meth1() is overridden in Sub1 and Super method
meth2() in Sub2. Super method meth0()is not overridden in the subclasses. Both
subclasses have a method named meth3(). Which of the statement in the main metho
d of the Test class will result in compilation error ?
}
} // overridden in Sub1
} // overridden in Sub2
}
} // only in suclasses
}
} // only in subclasses
s[i].meth0();
s[i].meth3();
s[i].meth1();
s[i].meth2();
Response was: B
Correct Correct (1 mark)
Question 11 (1 mark) Attempt 1
Which of the statement(s) below attempting to override method1() in subclass B i
s valid ?
class A {
void method1(int amount) {
}
}
class B extends A {
// method1 to be overridden here
}
A
B
C
D
Response was: A
Wrong Incorrect (0 mark)
modifier cannot be made more restrictive
Question 12 (1 mark) Attempt 1
Which of the following method is not a static method ?
A
sqrt() method of Math class
B
parseInt() method of Integer class
C
parseDouble() method of Double class
D
readLine() of BufferedReader class
Response was: D
Correct Correct (1 mark)
Question 13 (1 mark) Attempt 1
To be able to call a method using the class name rather than an instance name, t
he method will have to be declared ________
Response was: static
Correct Correct (1 mark)
Question 14 (1 mark) Attempt 1
Answer true or false
when applied to a method, static means that the method
can be called without creating instances of the class
A
B
false
true
Response was: B
Correct Correct (1 mark)
Question 15 (1 mark) Attempt 1
Answer true or false:
A class that has abstract methods must be declared abstract explicitly using
abstract modifier.
A
B
true
false
Response was: A
Correct Correct (1 mark)
Question 16 (1 mark) Attempt 1
Answer true or false:
A class that is declared abstract need not have abstract methods.
A
B
Response was: B
true
false
true
false
Response was: B
Wrong Incorrect (0 mark)
Question 18 (1 mark) Attempt 1
Given the declaration
float[] anArray = new float[256];
The following loop prints all the elements of the array back to front; select th
e most appropriate option to fill the blanks with the proper int numbers (such a
s 75, 9):
for (int i = ____; i >= ____ ; i--)
System.out.println(anArray[i]);
A
B
C
D
E
256,
255,
256,
255,
None
1
1
0
0
of the above - a for loop cannot count backwards.
Response was: C
Wrong Incorrect (0 mark)
Question 19 (1 mark) Attempt 1
Which of the following are valid method headers ?
A
public static int[] meth(int[] x)
B
public static int[] meth(int x)
C
public static int meth(int[] x)
D
public static int meth(int x)
Response was: B and D
Wrong Incorrect (0 mark)
an array can be passed as argument and can be returned
Question 20 (1 mark) Attempt 1
Which is the output of the program below ?
public class Test2DArray
{
public static void main (String[] args)
{
int[][] m = new int[3][3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
if (i == j)
m[i][j] = 1;
else
m[i][j] = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
System.out.print(" " + m[i][j]);
System.out.println();
}
}
}
A
0 1 0
0 1 0
0 1 0
B
0 1 0
1 0 1
0 1 0
C
0 0 0
1 1 1
0 0 0
D
1 0 0
0 1 0
0 0 1
Response was: D
Correct Correct (1 mark)