• ( 1 ) public class Test { }
      What is the prototype of the default constructor?

    • 1) public Test(void)
    • 2) Test( )
    • 3) Test(void)
    • 4) public Test( )
    • Discussion in forum
      Answer : 4) public Test( )
      Solution :








      discussion


      Answer : 4) public Test( )

    • ( 2 ) The implicit return type of a constructor is

    • 1) void
    • 2) A class object in which it is defined.
    • 3) There is no return type
    • 4) None of these
    • Discussion in forum
      Answer : 2) A class object in which it is defined.
      Solution :








      discussion


      Answer : 2) A class object in which it is defined.

    • ( 3 ) A constructor

    • 1) must have the same name as the class it is declared within.
    • 2) is used to create objects.
    • 3) may be declared private
    • 4) All of the above
    • Discussion in forum
      Answer : 4) All of the above
      Solution :








      discussion


      Answer : 4) All of the above

    • ( 4 ) What is the output for the below code ?
      class A{
      public A(){
      System.out.println("A");
      }
      public A(int i){
      this();
      System.out.println(i);
      }
      }
      class B extends A{
      public B(){
      System.out.println("B");
      }
      public B(int i){
      this();
      System.out.println(i+3);
      }
      }
      public class Test{
      public static void main (String[] args){
      new B(5);
      }
      }

    • 1) A B 8
    • 2) A 5 B 8
    • 3) A B 5
    • 4) B 8 A 5
    • Discussion in forum
      Answer : 1) A B 8
      Solution :








      discussion


      Answer : 1) A B 8

    • ( 5 ) Which method can be defined only once in a program?

    • 1) main method
    • 2) finalize method
    • 3) static method
    • 4) private method
    • Discussion in forum
      Answer : 1) main method
      Solution : main() method can be defined only once in a program. Program execution begins from the main() method by java’s run time system.








      discussion


      Answer : 1) main method

    • ( 6 ) What is the return type of Constructors?

    • 1) int
    • 2) float
    • 3) void
    • 4) None of these
    • Discussion in forum
      Answer : 4) None of these
      Solution : Constructors does not have any return type, not even void.








      discussion


      Answer : 4) None of these

    • ( 8 ) Which method of java is invoked by JVM to reclaim the inaccessible memory location

    • 1) reclaim() method
    • 2) final() method
    • 3) finalize() method
    • 4) Both 2 & 3
    • Discussion in forum
      Answer : 3) finalize() method
      Solution :








      discussion


      Answer : 3) finalize() method

    • ( 9 ) Which methods are utilized to control the access to an object in multi-threaded programming?

    • 1) Asynchronized methods
    • 2) Synchronized methods
    • 3) Serialized methods
    • 4) None of these
    • Discussion in forum
      Answer : 2) Synchronized methods
      Solution :








      discussion


      Answer : 2) Synchronized methods

    • ( 10 ) What is the output for the below code ?
      public class A{
      int add(int i, int j){
      return i+j;
      }
      }
      public class B extends A{
      public static void main(String argv[]){
      short s = 9;
      System.out.println(add(s,6));
      }

    • 1) Compile fail due to error on line no 2
    • 2) Compile fail due to error on line no 9
    • 3) Compile fail due to error on line no 8
    • 4) 15
    • Discussion in forum
      Answer : 2) Compile fail due to error on line no 9
      Solution :








      discussion


      Answer : 2) Compile fail due to error on line no 9





Top