stem.out.println(i);
}
A、 100 will be printed 11 times.
B、 100 will be printed 10 times and then there will be a runtime exception
C、 The code will not compile because the variable i cannot be declared twice within the mani() method.
D、 The code will not compile because the variable j cannot be declared twice within the switch statement.
E、 None of these.
7、 Which of the following collection classes from java.util package are Thread safe? (D)
A、 Vector B、 ArrayList C、 HashMap D、 Hashtable
8、 What will happen when you attempt to compile and run the following code? (A)
class MyThread extends Thread {
public void run() {
System.out.println("MyThread: run()");
}
public void start() {
System.out.println("MyThread: start()");
}
}
class MyRunnable implements Runnable {
public void run() {
System.
out.println("MyRunnable: run()");
}
public void start() {
System.out.println("MyRunnable: start()");
}
}
public class MyTest {
public static void main(String args[]) {
MyThread myThread = new MyThread();
MyRunnable myRunnable = new MyRunnable();
Thread thread = new Thread(myRunnable);
myThread.start();
thread.start();
}
}
A、 prints: MyThread: start() followed by MyRunnable: run()
B、 prints: MyThread: run() followed by MyRunnable: start()
C、 prints: MyThread: start() followed by MyRunnable: start()
D、 prints: MyThread: run() followed by MyRunnable: run()
E、 compile time error
F、 None of the above
9、 Which of the following will output -4.0?(3)
1、 System.out.println(Math.floor(-4.7));
2、 System.out.println(Math.round(-4.7));