Multiple Choice Questions
- Which is true? (Choose all that apply)
- "X extends Y" is correct if and only is X is a class and Y is an interface.
- "X extends Y" is correct if and only is X is an interface and Y is a class.
- "X extends Y" is correct if X and Y are either both classes or both interfaces.
- "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.
- Given:
- static void doStuff(int... doArgs) {}
- static void doStuff(int[] doArgs) {}
- static void doStuff(int doArgs...) {}
- static void doStuff(int doArgs..., int y) {}
- static void doStuff(int x, int... doArgs) {}
- Given:
- woof burble
- Multiple compilation errors
- Compilation fails due to an error on line 2
- Compilation fails due to an error on line 3
- Compilation fails due to an error on line 4
- Compilation fails due to an error on line 11
- Given two files:
- 5 6 7
- 5 followed by an exception
- Compilation fails due to an error on line 11
- Compilation fails due to an error on line 12
- Compilation fails due to an error on line 13
- Compilation fails due to an error on line 14
- Given
- Compilation succeeds
- Compilation fails due to an error on line 1
- Compilation fails due to an error on line 5
- Compilation fails due to an error on line 7
- Compilation fails due to an error on line 11
- Compilation fails due to an error on line 15
- Given
- Compilation succeeds
- Compilation fails due to an error on line 3
- Compilation fails due to an error on line 4
- Compilation fails due to an error on line 5
- Compilation fails due to an error on line 6
- Compilation fails due to an error on line 7
- Given
- TUE
- WED
- The output is unpredictable
- Compilation fails due to an error on line 2
- Compilation fails due to an error on line 4
- Compilation fails due to an error on line 6
- Compilation fails due to an error on line 7
- Given
- 13
- Compilation fails due to multiple errors
- Compilation fails due to an error on line 3
- Compilation fails due to an error on line 4
- Compilation fails due to an error on line 8
class Voop {
public static void main(String[] args) {
doStuff(1);
doStuff(1, 2);
}
// Insert your code here
}
Which statement can be inserted (Choose all that apply)?
enum Animals {
DOG("woof"), CAT("meow"), FISH("burble");
String sound;
Animals(String s) {
sound = s;
}
}
class TestEnum {
static Animals a;
public static void main(String[] args) {
System.out.println(a.DOG.sound + " " + a.FISH.sound);
}
}
What is the result?
package pkgA;
public class Foo {
int a = 5;
protected int b = 6;
public int c = 7;
}
package pkgB;
import pkgA.*;
public class Baz {
public static void main(String[] args) {
Foo f = new Foo();
System.out.print(" " + f.a);
System.out.print(" " + f.b);
System.out.print(" " + f.c);
}
}
What is the result? (Choose all that apply)
public class Electronic implements Device {
public void doIt() {
}
}
abstract class Phone1 extends Electronic {
}
abstract class Phone2 extends Electronic {
public void doIt(int x) {
}
}
class Phone3 extends Electronic implements Device {
public void doStuff() {
}
}
interface Device {
public void doIt();
}
What is the result? (Choose all that apply)
class Announce {
public static void main(String[] args) {
for(int __x = 0; __x < 3; __x++);
int #lb = 7;
long [] x [5];
Boolean []ba[];
enum Traffic {RED, YELLOW, GREEN}; }
}
What is the result? (Choose all that apply)
public class TestDays {
public enum Days { MON, TUE, WED };
public static void main(String[] args) {
for (Days d : Days.values())
;
Days[] d2 = Days.values();
System.out.println(d2[2]);
}
}
What is the result? (Choose all that apply)
public class Frodo extends Hobbit {
public static void main(String[] args) {
Short myGold = 7;
System.out.println(countGold(myGold, 6));
}
}
class Hobbit {
int countGold(int x, int y) {
return x + y;
}
}
What is the result?
Comments
Post a Comment