0
0
Javaprogramming~5 mins

Partial abstraction in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is partial abstraction in Java?
Partial abstraction means a class has some methods with implementation and some without. It is done using <code>abstract</code> classes that can have both abstract and concrete methods.
Click to reveal answer
beginner
How do you declare an abstract method in Java?
Use the abstract keyword before the method signature and do not provide a body. For example: abstract void display();
Click to reveal answer
beginner
Can you create an object of an abstract class?
No, you cannot create an object of an abstract class directly. You must create a subclass that implements the abstract methods and then create an object of that subclass.
Click to reveal answer
intermediate
Why use partial abstraction instead of full abstraction?
Partial abstraction lets you share common code in the abstract class while forcing subclasses to provide specific details. It helps avoid code duplication and provides a template for subclasses.
Click to reveal answer
beginner
Example of a partial abstraction in Java?
An abstract class Animal with an abstract method sound() and a concrete method sleep(). Subclasses like Dog implement sound().
Click to reveal answer
Which keyword is used to declare a class with partial abstraction in Java?
Aabstract
Bpartial
Cinterface
Dfinal
Can an abstract class have implemented methods?
AYes, it can have both abstract and concrete methods
BNo, all methods must be abstract
COnly static methods can be implemented
DOnly private methods can be implemented
What happens if a subclass does not implement all abstract methods?
AIt will compile without errors
BIt becomes a concrete class
CIt must be declared abstract
DIt automatically implements methods
Which of these is NOT true about partial abstraction?
AIt uses abstract classes
BIt cannot be instantiated directly
CIt allows some methods to have code
DIt requires all methods to be abstract
Why might you choose partial abstraction over interfaces?
ABecause interfaces cannot have methods
BTo provide common method implementations
CTo force all methods to be abstract
DTo allow object creation of the abstract class
Explain partial abstraction in Java and how it differs from full abstraction.
Think about classes that have some methods with code and some without.
You got /5 concepts.
    Describe a simple example of partial abstraction using an abstract class and a subclass.
    Use an animal or vehicle example.
    You got /4 concepts.