- What will happen when you
attempt to compile and run the following code?
class Mammal{
Mammal(){
System.out.println("Four");
}
public void ears() {
System.out.println("Two");
}
}
class Dog extends
Mammal{
Dog() {
super.ears();
System.out.println("Three");
}
}
public class Scottie
extends Dog{
public static void
main (String args[ ]){
System.out.println("One");
Scottie d = new
Scottie();
}
}
- One, Two, Three, Four
- One, Four, Three, Two
- One, Four, Two, Three
- Compile time error
- None of the above
- What will happen when you
attempt to compile and run the following code?
public class RunT
implements Runnable {
public static void
main (String args[ ]) {
RunT r = new RunT();
Thread t = new
Thread(r);
t.start();
}
public void start ()
{
for(int i = 0; i<
100; i++)
System.out.println(i);
}
}
- Compilation and output of
count from 0 to 99
- Compilation and no output
- Compile time error: class
RunT is an abstract class. It can’t be instantiated
- Compile time error, method
start cannot be called directly
- What will happen when you
attempt to compile and run the following code?
public class RunT
extends Thread {
public static void
main (String args[ ]) {
RunT r = new RunT();
t.run();
}
public void run () {
for(int i = 0; i<
100; i++)
System.out.println(i);
}
}
A. Compilation and
output of count from 0 to 99
- Compilation and no output
- Compile time error: class
RunT is an abstract class. It can’t be instantiated
- Compile time error, method
start has not been defined
- Which of the following are
ture?
- Java uses a time-slicing
scheduling system for determining which Thread will execute
- Java uses pre-emptive,
co-operative system for determining which Thread will execute
- Java scheduling is platform
dependent and may vary from one implementation to another
- You can set the priority of
a Thread in Java
- How do you indicate where a
component will be positioned in FloeLayout?
- North, South, East, West
- Assign a row/column grid
reference
- Pass a X/Y percentage
parameter to add method
- Do nothing, the FlowLayout
will position the component
- What will happen when you add
a vertical scroll bar to the North of a Frame?
- The frame will enlarge to
allow the scrollbar to become its preferred size
- It will be wide, fat and not
very useful
- You cannot add a vertical scrollbar
to the North of a frame, only the East or West
- The scrollbar will stretch
from the top to the bottom of the Frame
- Which of the following
Components are not Containers?
- Frame
- Window
- Applet
- List
- None of the above
- Which of the following
Containers are not Components?
- Frame
- Window
- Applet
- List
- None of the above
- Which of the following will
compile correctly?
- boolean b = -1;
- int i = 19;
- char c = 99;
- char c = "a";
- Which of the following is not
compile?
- String s = "abcd"
;
- String s = new String
("abcd");
- String s = ‘ 99’;
- String s = new String
(char); where char is an array of char types