316). Which of these keywords can be used to prevent inheritance of a class?

[A]super
[B]constant
[C]class
[D]final

Show Answer

317). Which of these keywords cannot be used for a class which has been declared final?

[A]abstract
[B]extends
[C]abstract and extends
[D]none of the mentioned

Show Answer

319). What will be the output of the following Java program?
    abstract class A 
    {
        int i;
        abstract void display();
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            System.out.println(j);
        }
    }    
    class Abstract_demo 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.j=2;
            obj.display();    
        }
    }

[A]0
[B]2
[C]Runtime Error
[D]Compilation Error

Show Answer

320). What will be the output of the following Java program?
   class A 
   {
	int i;
	int j;
        A() 
        {
            i = 1;
            j = 2;
        }
   }
   class Output 
   {
        public static void main(String args[])
        {
             A obj1 = new A();
             A obj2 = new A();
	     System.out.print(obj1.equals(obj2));
        }
   }

[A]false
[B]true
[C]1
[D]Compilation Error

Show Answer

321). What will be the output of the following Java code?
    class Output 
    {
        public static void main(String args[])
        {
             Object obj = new Object();
	     System.out.print(obj.getclass());
        }
    }

[A]Object
[B]class Object
[C]class java.lang.Object
[D]Compilation Error

Show Answer

322). What will be the output of the following Java code?
   class A 
   {
        int i;
	int j;
        A() 
        {
            i = 1;
            j = 2;
        }
   }
   class Output 
   {
        public static void main(String args[])
        {
             A obj1 = new A();
	     System.out.print(obj1.toString());
        }
   }

[A]true
[B]false
[C]String associated with obj1
[D]Compilation Error

Show Answer