Govt Exams
When no access modifier is specified, the member has package-private (default) access, visible only within the same package.
Interfaces cannot be instantiated directly. You can only create objects of classes that implement interfaces.
The 'final' keyword prevents a class from being extended. For example: final class MyClass {} cannot be subclassed.
If no access modifier is specified for a class member, it has package-private (default) access, meaning it's accessible only within the same package.
All members in an interface are implicitly public. Variables are public static final, and methods are public abstract (unless default or static).
Java supports only single class inheritance to avoid the diamond problem. However, multiple interface implementation is allowed.
Java achieves runtime polymorphism through method overriding using inheritance. Unlike C++, Java doesn't use the 'virtual' keyword; it's implicit for all non-final methods.
Interfaces cannot be instantiated directly. You must create a concrete class that implements the interface or use an anonymous inner class.
Encapsulation is the bundling of data (variables) and methods into a single unit (class) while hiding the internal implementation details from the outside world. It is achieved using access modifiers.
The 'extends' keyword creates an inheritance relationship where Child inherits properties and methods from Parent. This is an 'is-a' relationship.