Abstract Classes In Java: Trivia Quiz!

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Geetha Venugopal
Geetha Venugopal, Computer Education
Geetha, a certified IT educator with 30+ years of experience, inspires self-efficacy in students from G3 to AP & IB levels. Her teaching is collaborative, tech-driven, and aligned with diverse curriculum needs.
Quizzes Created: 2 | Total Attempts: 8,894
| Attempts: 4,067 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. What is an abstract method?

Explanation

An abstract method is a method that is declared in an abstract class but does not have any implementation. It serves as a placeholder for the method that needs to be implemented in a non-abstract class that extends the abstract class. This allows for the abstraction of common functionality in the abstract class while leaving the specific implementation details to the subclasses.

Submit
Please wait...
About This Quiz
Abstract Classes In Java: Trivia Quiz! - Quiz


What do you understand about abstract classes in Java? Would you be interested in trying this quiz? Everything in Java is connected with classes and objects, along with... see moreits characteristics, including weight and color, as well as methods such as drive and brake. A class can be compared to a blueprint for creating items, as they are basic programming concepts. If you want to learn more about Java taking this quiz is worth your time. see less

2. What is an abstract class?

Explanation

An abstract class is a class that cannot be instantiated and is meant to serve as a base class for other classes. It may have abstract methods, which are methods without any implementation, and these methods must be implemented by the child classes that inherit from the abstract class. This allows the abstract class to define a common interface or behavior that the child classes must adhere to. Therefore, an abstract class is a class that has at least one abstract method and cannot be instantiated directly.

Submit
3. In order for the following code to be correct, what must be the type of the reference variable card? ____________________ card; card=new Valentine("Joe",14); card=new Holiday("Bob"); card=new Birthday("Emily",12);

Explanation

The reference variable "card" must be of type "Card" in order for the code to be correct. This is because the code assigns different types of objects (Valentine, Holiday, and Birthday) to the "card" variable. In order for this assignment to work, the variable must be able to hold objects of any subclass of the "Card" class.

Submit
4. Can an abstract class define both abstract methods and non-abstract methods?

Explanation

Yes, an abstract class can define both abstract methods and non-abstract methods. The child classes that inherit from the abstract class will inherit both types of methods. Abstract methods are those that are declared in the abstract class but do not have an implementation. They must be implemented by the child classes. Non-abstract methods, on the other hand, have a complete implementation in the abstract class itself and can be directly used by the child classes without any modification.

Submit
5. What is an interface?

Explanation

An interface is a collection of abstract methods and constants. It is a way to define a contract for classes that implement it, specifying the methods that must be implemented and the constants that must be defined. By using interfaces, we can achieve abstraction and provide a common set of methods and constants that can be used by multiple classes. Classes implementing an interface must provide the implementation for all the abstract methods defined in the interface.

Submit
6. Dynamic Binding or Late Binding is:

Explanation

Dynamic Binding or Late Binding refers to the process of connecting a method with its parameters during runtime. This occurs when there is an overridden method, meaning that a subclass has defined a method with the same name and signature as a method in its superclass. During execution, the appropriate method is determined based on the actual object type rather than the reference type, allowing for polymorphism and the ability to invoke different implementations of the same method. This enables greater flexibility and extensibility in object-oriented programming.

Submit
7. Interfaces can contain _________________ and _____________________ and abstract classes can contain _____________________ ,  ______________________and at least ___  ____________________________________   __________________

Explanation

Interfaces can contain abstract methods, constants, instance variables, and implemented methods. Abstract classes can contain abstract methods, constants, variables, implemented methods, and at least one abstract method.

Submit
8. What is Polymorphism in Java?

Explanation

Polymorphism in Java refers to the feature of deciding which overridden method will be used at the run time of a program. It allows objects of different classes to be treated as objects of a common superclass, enabling flexibility and code reusability. This feature is achieved through method overriding, where a subclass provides its own implementation of a method that is already defined in its superclass. At runtime, the JVM determines which version of the method to execute based on the actual type of the object being referred to.

Submit
9. Does a subclass that extends an abstract class have to give implementation to all the abstract methods of the superclass?

Explanation

If a subclass extends an abstract class, it does not necessarily have to give implementation to all the abstract methods of the superclass. This is because the subclass itself can also be declared as abstract, which means it does not need to provide implementation for the abstract methods. Therefore, the correct answer is "not necessarily if the sub class is going to be declared abstract."

Submit
10. What determines what method is run in the following?

Card crd=new Birthday("Lucinda",42);
crd.greeting();

Explanation

The type of the object determines what method is run in the given code. This is because the object is created using the "new" keyword with the type "Birthday", which is a subclass of the "Card" class. Since the object is of type "Birthday", the method "greeting()" in the "Birthday" class will be executed. This is known as dynamic method dispatch, where the method to be executed is determined at runtime based on the actual type of the object.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 24, 2009
    Quiz Created by
    Geetha Venugopal
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is an abstract method?
What is an abstract class?
In order for the following code to be correct, what must be the type...
Can an abstract class define both abstract methods and non-abstract...
What is an interface?
Dynamic Binding or Late Binding is:
Interfaces can contain _________________ and _____________________ and...
What is Polymorphism in Java?
Does a subclass that extends an abstract class have to give...
What determines what method is run in the following?Card crd=new...
Alert!

Advertisement