OBJECT ORIENTED PROGRAMMING USING JAVA QUIZ 1.2

OBJECT ORIENTED PROGRAMMING USING JAVA QUIZ 1.2


An abstract class in Java usually contains one or more abstract ____.
a. Constructors
b. Variables
c. Methods
d. None of the above


Which is the opposite of an Abstract Class?
a. Interface
b. Concrete class


To create an Abstract class, the keyword “class” is also required. State TRUE or FALSE.
Select one:
True
False


What is the output of the below Java program with an abstract class?

abstract class Coffee
{
Coffee()
{
System.out.println("Inside Constructor of Coffee..");
}
}
class ColdCoffee extends Coffee
{
ColdCoffee()
{
System.out.println("Inside Constructor of ColdCoffee..");
}
}
public class AbstractClassTesting
{
public static void main(String[] args)
{
ColdCoffee cf = new ColdCoffee();
}
}

a. Inside Constructor of ColdCoffee..
b. Inside Constructor of Coffee..
Inside Constructor of ColdCoffee..

c. Compiler error
d. Inside Constructor of Coffee..


Does the below Java code with abstract method compile?

class Puppy
{
abstract void showName();
}

a. Yes
b. No


You can create an object from an abstract class in Java. True or False?
Select one:
True
False


What is the output of the below Java program with an abstract class?

abstract class MathLibrary
{
static final float PI = 3.1415f;
}
public class AbstractClassTesting3
{
public static void main(String[] args)
{
System.out.println(MathLibrary.PI);
}
}

a. No output
b. Compilation error
c. 3.1415
d. None of the above


What is method overriding in Java?
a. Writing a method in a subclass with the same name of superclass’s method
b. Mentioning the same return type of the method of the superclass
c. The argument list in the method of subclass and the method of superclass should be the same
d. All of the above



The content uploaded on this website is for reference purposes only. Please do it yourself first.
Home
Account
Cart
Search