Abstract Classes In Java: Trivia Quiz!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
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,349
Questions: 10 | Attempts: 3,602

SettingsSettingsSettings
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 its 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.


Questions and Answers
  • 1. 

    What is an abstract class?

    • A.

      An abstract class is one without any child classes.

    • B.

      An abstract class is any parent class with more than one child class

    • C.

      An abstract class is a class which has at least one abstract method which cannot be instantiated.

    • D.

      Is a "base class"

    Correct Answer
    C. An abstract class is a class which has at least one abstract method which cannot be instantiated.
    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.

    Rate this question:

  • 2. 

    What is an abstract method?

    • A.

      Is any method in an abstract class

    • B.

      Is a method which cannot be inherited

    • C.

      A method which is not implemented. The implementation for this method needs to be done in a non abstract class which extends this class.

    • D.

      Is a method in the child class that overrids a parent method

    Correct Answer
    C. A method which is not implemented. The implementation for this method needs to be done in a non abstract class which extends this class.
    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.

    Rate this question:

  • 3. 

    Can an abstract class define both abstract methods and non-abstract methods?

    • A.

      Yes - the child classes will inherit both

    • B.

      Yes - but the child classes do not inherit the abstract methods

    • C.

      No--it must have all abstract methods

    • D.

      No--it must have all one or the other

    Correct Answer
    A. Yes - the child classes will inherit both
    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.

    Rate this question:

  • 4. 

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

    • A.

      Not necessarily if the sub class is going to be declared abstract

    • B.

      Yes-an abstract parent must have abstract children

    • C.

      No--an abstract parent mu have no children at all

    • D.

      Yes --all children of an abstract parent must be non-abstract

    Correct Answer
    A. Not necessarily if the sub class is going to be declared abstract
    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."

    Rate this question:

  • 5. 

    What is an interface?

    • A.

      A class with at least one abstract methods

    • B.

      A collection of abstract methods and constants

    • C.

      A super class with abstract method

    • D.

      A sub class with abstract method

    Correct Answer
    B. A collection of abstract methods and constants
    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.

    Rate this question:

  • 6. 

    What is Polymorphism in Java?

    • A.

      An object which has abstract method

    • B.

      Multiple inheritance - polymorphism

    • C.

      Hiding under a different name

    • D.

      The feature of deciding which overridden method will be used at the run time of a prgram

    Correct Answer
    D. The feature of deciding which overridden method will be used at the run time of a prgram
    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.

    Rate this question:

  • 7. 

    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);

    • A.

      Valentine

    • B.

      Holilday

    • C.

      Birthday

    • D.

      Card

    Correct Answer
    D. Card
    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.

    Rate this question:

  • 8. 

    Dynamic Binding or Late Binding is:

    • A.

      Connecting the method and the parameters

    • B.

      Because of overridden method and the use of the appropriate method during execution

    • C.

      Because of overloaded methods

    • D.

      When formal parameters and actual parameters differ

    Correct Answer
    B. Because of overridden method and the use of the appropriate method during execution
    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.

    Rate this question:

  • 9. 

    What determines what method is run in the following?Card crd=new Birthday("Lucinda",42);crd.greeting();

    • A.

      The reference type of the object reference variable

    • B.

      The type of the object

    • C.

      The type of the class

    • D.

      The Type of the constructors

    Correct Answer
    B. The type of the object
    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.

    Rate this question:

  • 10. 

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

    • A.

      Variables, constants,abstract methods and non abstract methods

    • B.

      Abstract methods,constants,instance variables, implemented methods and one abstract method

    • C.

      Constants, implemented methods, variables, abstract methods, overridden methods

    Correct Answer
    B. Abstract methods,constants,instance variables, implemented methods and one abstract method
    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.

    Rate this question:

Quiz Review Timeline +

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
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.