Java - Abstraction

page 1 out of 3

page 1 out of 3


Question 1     

Which two classes use the Shape class correctly?

A. public class Circle implements Shape 
   {
    private int radius;
   }
B. public abstract class Circle extends Shape 
   {
    private int radius;
   }
C. public class Circle extends Shape 
   {
   private int radius;
   public void draw();
   }
D. public abstract class Circle implements Shape 
   {
    private int radius;
    public void draw();
   }
E. public class Circle extends Shape 
   {
    private int radius;
    public void draw()
    {
     /* code here */
    }
   }
F. public abstract class Circle implements Shape 
   {
     private int radius;
     public void draw() 
     { 
      /* code here */ 
     }
   }





Question 2     

Which of the following is true?

1. An interface can extend many interfaces.

2. A class can extend more than one class.

3. A class can extend only one class but many interfaces.

4. A class can extend one class and implement many interfaces.

5. An interface can implement many interfaces.








Question 3     

What will be a class inheriting an abstract class and not define all of its functions?






Question 4     

Which package has the abstract key word?






Question 5     

What is the output of the following code?

abstract class Parent
{
    int i;
    abstract void display();
}
class Child extends Parent 
{
    int j;
    void display() 
    {
        System.out.println(j);
    }
}    
class Abstract_demo 
{
    public static void main(String args[])
    {
        Child obj = new Child();
        obj.j=2;
        obj.display();
    }
}






Question 6     

Which of the following is not Abstract






Question 7     

Which keyword should be used to inherit an interface?






Question 8     

Which of the following satisfy multiple inheritance






Question 9     

Find the statement which is true according to the following code?

class Demo 
{
   public abstract void display();
}





page 1 out of 3

page 1 out of 3


Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.