1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is an abstract class?
A class that cannot be instantiated; may contain abstract (no body) and concrete methods.
Can abstract classes have constructors?
Yes, subclasses can call them with super().
What keyword is used for inheritance?
extends
What is polymorphism?
When a superclass reference points to a subclass object, and the actual method called depends on the object type.
Can a class extend multiple classes?
No, Java supports only single inheritance.
What keyword is used to implement an interface?
implements
What can an interface contain?
Abstract methods (by default), default/static methods, and public static final constants.
Can a class implement multiple interfaces?
Yes, multiple interfaces are allowed.
Why can't you use ArrayList
Generics work only with objects, not primitives.
What is the workaround for ArrayList
Use the wrapper class: ArrayList
What is autoboxing?
Automatic conversion from primitive → wrapper (int → Integer).
What is unboxing?
Automatic conversion from wrapper → primitive (Integer → int).
What is the wrapper class for double?
Double
Comparable vs Comparator — key difference?
Comparable = natural order (inside class, compareTo). Comparator = flexible order (outside class, compare).
Can you have multiple Comparators for a class?
Yes, you can define as many as needed.
Can you have multiple Comparables for a class?
No, only one natural order.
What does static mean for a variable?
Shared by all objects; class-level.
What does static mean for a method?
Belongs to the class; can be called without creating an object.
Can a static method access instance variables directly?
No, because it has no this (no object context).
Why is main static?
So the JVM can call it without creating an object first.
Dynamic Binding or Late Binding is
Because of overridden method and the use of the appropriate method during execution
What is an interface
A collection of abstract methods and constants
What is Polymorphism in Java?
dThe feature of deciding which overridden method will be used at the run time of a program