public class Test { public static void main(String[] args) { .... } } >java Test This is a test a. "This" b. "is" c. "a" d. "test"
a. public null aMethod(); b. public void aMethod(); c. public aMethod(); d. public Pet aMethod();
a. String s = (String)100; b. Float f = 1.2f; c. double d = 0; d. String str = "s";
a. True b. False
a. Default constructor is a constructor that takes no arguments b. Default constructor is a constructor that takes only one argument c. Default constructor is a constructor existing only in your super class d. If you define no constructors at all in a class, then the compiler provides a default constructor.
a. A class field is declared with static modifier b. A class field is declared with non-static modifier c. A class field is declared without any modifier d. A class field is associated with the class in which it is defined.
a. public final double PI = 3.1415926; b. public final PI = 3.1415926; c. public double PI = 3.1415926; d. int PI = (int)3.1415926;
public class MyCounter { int counter; public static void main(String[] args) { counter++; System.out.println("counter: " + counter); } } What will happen when you attemp to compile and run it? a. You get a compile-time error. b. You get printout "counter: 1" on the screen. c. You get printout "counter: 0" on the screen. d. You get no printout on the screen.
a. True b. False
a. & b. && c. || d. |
class Bar { public static void main(String[] args) { String ch = args[0]; switch (ch) { case 1: System.out.println("You got 1"); break; case 2: System.out.println("You got 2"); break; default: System.out.println("Wrong data"); } } } a. You compile and run successfully b. You will get compile-time error because incompatible type. c. If you pass message 1, the printout is "You got 1". d. If you pass message 2, the printout is "You got 2".
a. True. b. False.
a. FlowLayout b. BorderLayout c. GridLayout d. GridBagLayout e. CardLayout
a. ClosingAdapter b. ActionAdapter c. ActivateAdapter d. ItemAdapter e. WindowAdapter
a. int i[5][]; b. int i[][]; c. int []i[1]; d. int i[5][5]; e. int[][] a;
a. %abcd b. 5abcd c. 1abcd d. package e. _a_long_name
class Sun extends Star { public Sun() { System.out.println("Star Wars1"); } public Sun(String v1) { super(v1, "Saturn"); System.out.println("Star Wars2"); } public Sun(String v2, String v3) { if ( v2.substring(0, v2.length()).length() > v3.length()) System.out.println("Mission to Mars"); else System.out.println("Earth"); } } a. 0 b. 1 c. 2 d. 3
a. True b. False
a. True b. False
a. True b. False
a. NO. By extending to the Frame class, there is no need to instantiate Frame in your class to get to its methods. b. YES.
a. Panel is not a class predefined by SUN. b. Panel is the super class of Frame. c. Panel is the super class of Object. d. Panel is a container that can hold other components, containers, and has a layout manager associated with it.
a. True b. False
a. because these fields are static b. because these fields are constants and conform to naming conventions. Constants are written in all uppercase letters. c. because these fields are non-static d. because these fields are public
public int XXX(int a, int b) { if ( a > b) return a; else return b; } a. Return a value b. Find a larger value, and its name is max c. Find a smaller value, and its name is min d. None of the above.
Answers: