PROG3112 Programming Java NCIII Part 2 WEEK 10 FIRST
PROG3112 Programming Java NCIII Part 2 WEEK 10 FIRST
Java supports ________; collections of related methods that typically enable you to tell objects what to do,
but not how to do it (we’ll see an exception to this in Java SE 8).
Answer: interfaces
Mike Danielle Adaure
Consider the array:
s[0] = 7
s[1] = 0
s[2] = -12
s[3] = 9
s[4] = 10
s[5] = 3
s[6] = 6
To change to the completed application’s directory, we opened a command window and used the
________ command to change to the directory (also called a folder) for the Painter application.
Answer: cd
int result = 0;
System.out.print("Hello ");
System.out.println("World");
Answer: the object’s toString method is implicitly called to obtain the String representation of the object
The class extension on a file means that the file:
Answer: is produced by the Java compiler (javac).
Which of the following is the correct statement to return JAVA?
Answer: "Java".toUpperCase()
Which of the following data items are arranged from the smallest to the largest in the data hierarchy.
Answer: bits, characters, fields, records, files.
Which primitive type can hold the largest value?
Answer: double (POSSIBLE) long| int (INCORRECT)
A new class of objects can be created conveniently by ________; the new class (called the ________) starts
with the characteristics of an existing class (called the ________), possibly customizing them and adding
unique characteristicsof its own.
Answer: inheritance, subclass, superclass
What will be output after the following Java statements have been executed (assume all variables are of
type int)?
a = 4;
b = 12;
c = 37;
d = 51;
if (a < b) {
System.out.println("a < b");
}
if (a > b) {
System.out.println("a > b");
}
if (d <= c) {
System.out.println("d <= c");
}
if (c != d) {
System.out.println("c != d");
}
Answer: a<b
c != d
Which of the following code displays the area of a circle if the radius is positive?
Answer: if (radius > 0) System.out.println(radius * radius * 3.14159);