1. Which of these is the correct declaration for main?
    1. public static void main()
    2. public void static main(String args[ ])
    3. public static void main(String args)
    4. public static void main(String args[ ])
    5. public static void main(String[ ] args)
  1. What will happen when you attempt to compile and run the following code?

import java.awt.*;

import java.awt.event.*;

public class MClick extends Frame implements MouseListener{

public static void main(String arg[]){

MClick m = new MClick();

}

MClick() {

this.addMouseListener(this);

}

public void mouseClicked (MouseEvent me){

System.out.println("Event occured");

}

}

    1. Compile time error
    2. Run time Error
    3. Compile and at runtime "Event occurred" will be the output
    4. Compile and at runtime no action is performed
  1. What code can you write to ensure that the int variables are garbage collected at a particular point in this code?

public class Rub{

int i = 1;

int j = 2;

int k = 3;

public static void main(String args[ ]){

Rub r = new Rub();

r.amethod();

}

public void amethod (){

i = 0;

j = 0;

k = 0;

}

}

    1. System.gc();
    2. System.free();
    3. Set the value of each int to null.
    4. None of the above
  1. Given the following main method in a class Bike and a command line of

Java Bike one two

what will be the output?

public static void main (String bikes[ ]){

System.out.println(bikes[1]);

}

    1. None of these options
    2. bikes
    3. one two
    4. one
    5. two
  1. Which of the following are Java key words?
  1. double
  2. Switch
  3. then
  4. instanceof
  1. What will happen when you attempt to compile and run the following code?

public class MyParm{

public static void main (String arg[ ]){

String s1 = "One";

String s2 = "One";

if (s1.equals(s2)) {

System.out.println("Strings are equal");

boolean b1 = true;

boolean b2 = true;

if (b1.equals(b2)) {

System.out.println("true");

}

}

}

  1. Compile time error
  2. Run time error
  3. Only "Strings are equal"
  4. "Strings are equal" followed by "true"
  1. What will happen when you attempt to compile and run the following code?

Object o1 = new Object();

Object o2 = new Object();

o1= o2;

if (o1.equals(o2))

System.out.println("Equals");

}

  1. Compile time error
  2. Run time error
  3. "Equals"
  4. NullPointerException will be thrown
  1. What will happen when you attempt to compile and run the following code?

class Base {

int I = 99;

public void amethod () {

System.out.print("Base.amethod()");

}

Base() {

amethod();

}

}

public class Ret extends Base {

int i = -1;

public static void main (String args[ ]) {

Base b = new Ret();

System.out.print(b.i);

b.amethod();

}

public amethod() {

System.out.print("Ret.amethod()");

}

}

  1. Ret.amethod() -1 Ret.amethod()
  2. Ret.amethod() 99 Ret.amethod()
  3. 99 Ret.amethod()
  4. Compile Time error
  1. Which are the three characteristics of Object Oriented programming?
  1. encapsulation, dynamic binding, polymorphism
  2. polymorphism, overloading, overriding
  3. encapsulation, inheritance, polymorphism
  4. encapsulation, inheritance, dynamic binding
  1. Which of the following statements are ture?
  1. Constructors are not inherited
  2. Constructors can be overridden
  3. A parental constructor can be invoked using this
  4. Any method may contain a call to this or super