Quiz Discussion

If super class and subclass have same variable name, which keyword should be used to use super class?

Course Name: Java

  • 1]

    super

  • 2]

    this

  • 3]

    upper

  • 4]

    classname

Solution
No Solution Present Yet

Top 5 Similar Quiz - Based On AI&ML

Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api

# Quiz
1
Discuss

What is not type of inheritance?

  • 1]

    Single inheritance

  • 2]

    Double inheritance

  • 3]

    Hierarchical inheritance

  • 4]

     Multiple inheritance

Solution
2
Discuss

What will be the output of the following Java program?

    class A 
    {
        int i;
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            super.i = j + 1;
            System.out.println(j + " " + i);
        }
    }    
    class inheritance 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.i=1;
            obj.j=2;   
            obj.display();     
        }
   }

 

  • 1]

    2 2

  • 2]

    3 3

  • 3]

    2 3

  • 4]

    3 2

Solution
3
Discuss

Which of this keyword must be used to inherit a class?

  • 1]

    super

  • 2]

    this

  • 3]

    extent

  • 4]

    extends

Solution
4
Discuss

What will be the output of the following Java program?

    class A 
    {
        public int i;
        public int j;
        A() 
        {
            i = 1;
            j = 2;
	}
    }    
    class B extends A 
    {
        int a;
        B() 
        {
            super();
        } 
    }    
    class super_use 
    {
        public static void main(String args[])
        {
            B obj = new B();
            System.out.println(obj.i + " " + obj.j)     
        }
   }

 

  • 1]

    1 2
     

  • 2]

    2 1

  • 3]

    Runtime Error

  • 4]

    Compilation Error

Solution
5
Discuss

Does Java support multiple level inheritance?

  • 1]

    True

  • 2]

    False

Solution
6
Discuss

Using which of the following, multiple inheritance in Java can be implemented?

  • 1]

    Interfaces

  • 2]

    Multithreading

  • 3]

    Protected methods

  • 4]

    Private methods

Solution
7
Discuss

Which of these is correct way of inheriting class A by class B?

  • 1]

    class B + class A {}

  • 2]

    class B inherits class A {}

  • 3]

    class B extends A {}

  • 4]

    class B extends class A {}

Solution
8
Discuss

What will be the output of the following Java program?

    class A 
    {
        int i;
        void display() 
        {
            System.out.println(i);
        }
    }    
    class B extends A 
    {
        int j;
        void display() 
        {
            System.out.println(j);
        }
    }    
    class inheritance_demo 
    {
        public static void main(String args[])
        {
            B obj = new B();
            obj.i=1;
            obj.j=2;   
            obj.display();     
        }
   }

 

  • 1]

    0

  • 2]

    1

  • 3]

    2

  • 4]

    Compilation Error

Solution
9
Discuss

All classes in Java are inherited from which class?

  • 1]

    java.lang.class

  • 2]

    java.class.inherited

  • 3]

    java.class.object

  • 4]

    java.lang.object

Solution
10
Discuss

Which of the following is used for implementing inheritance through an interface?

  • 1]

    inherited

  • 2]

    using

  • 3]

    extends

  • 4]

    implements

Solution
# Quiz