1. 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();

}

}

  1. One, Two, Three, Four
  2. One, Four, Three, Two
  3. One, Four, Two, Three
  4. Compile time error
  5. None of the above
  1. 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);

}

}

  1. Compilation and output of count from 0 to 99
  2. Compilation and no output
  3. Compile time error: class RunT is an abstract class. It can’t be instantiated
  4. Compile time error, method start cannot be called directly
  1. 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

  1. Compilation and no output
  2. Compile time error: class RunT is an abstract class. It can’t be instantiated
  3. Compile time error, method start has not been defined
  1. Which of the following are ture?
  1. Java uses a time-slicing scheduling system for determining which Thread will execute
  2. Java uses pre-emptive, co-operative system for determining which Thread will execute
  3. Java scheduling is platform dependent and may vary from one implementation to another
  4. You can set the priority of a Thread in Java
  1. How do you indicate where a component will be positioned in FloeLayout?
  1. North, South, East, West
  2. Assign a row/column grid reference
  3. Pass a X/Y percentage parameter to add method
  4. Do nothing, the FlowLayout will position the component
  1. What will happen when you add a vertical scroll bar to the North of a Frame?
  1. The frame will enlarge to allow the scrollbar to become its preferred size
  2. It will be wide, fat and not very useful
  3. You cannot add a vertical scrollbar to the North of a frame, only the East or West
  4. The scrollbar will stretch from the top to the bottom of the Frame
  1. Which of the following Components are not Containers?
  1. Frame
  2. Window
  3. Applet
  4. List
  5. None of the above
  1. Which of the following Containers are not Components?
  1. Frame
  2. Window
  3. Applet
  4. List
  5. None of the above
  1. Which of the following will compile correctly?
  1. boolean b = -1;
  2. int i = 19;
  3. char c = 99;
  4. char c = "a";
  1. Which of the following is not compile?
  1. String s = "abcd" ;
  2. String s = new String ("abcd");
  3. String s = ‘ 99’;
  4. String s = new String (char); where char is an array of char types