Last 10 Years Most Asked Oops Interview Question In MNC's

Why take this course?
-
Yes, a superclass reference variable can hold an object of a subclass because in Java, every object implicitly is an instance of its most specific class (subclass) as well as an instance of its supertypes (superclass).
-
No, multiple inheritance is not allowed in Java. Java supports single inheritance where a class can extend only one superclass. However, a class can implement multiple interfaces.
-
An interface is an abstract definition of a concept that specifies behaviors without providing the concrete implementation details of those behaviors. Interfaces allow any class to take on some capabilities by implementing them.
-
An interface is defined using the
interface
keyword followed by a list of method signatures, with no body. For example:
public interface MyInterface {
void myMethod();
}
- A class implements an interface by providing concrete implementations for the methods declared in the interface. For example:
public class MyClass implements MyInterface {
public void myMethod() {
// Implementation details
}
}
- A few tricky things about interfaces include:
- An interface can extend multiple interfaces, but a class can only extend one superclass.
- A class implementing an interface must implement all of its abstract methods unless it declares itself to be abstract as well.
- Since Java 7 and 8, interfaces can declare static methods (default methods) and fields (static fields).
- Interfaces cannot be instantiated; they are reference types.
-
Yes, you can extend an interface in Java. An interface can inherit from another interface or implement methods from another interface since Java 8.
-
Yes, a class can extend multiple interfaces. A class can implement as many interfaces as it needs.
-
An abstract class is a class that cannot be instantiated—it must be subclassed and the subclasses must provide concrete implementations of its abstract methods, if any. Abstract classes are used when you want to provide some common base functionality for multiple classes.
-
You use an abstract class when there is common implementation for several concrete classes, or when you want to declare a method that will not have a body (an abstract method) to be implemented by subclasses.
-
An abstract method is defined without an implementation (just the method signature) and is typically used within an abstract class. It's declared using the
abstract
keyword. For example:
public abstract class MyAbstractClass {
public abstract void myMethod();
}
The rest of the questions you've listed cover a wide range of Java concepts, from OOP principles to language-specific syntax and best practices. If you have any specific question from that list or any other topic, feel free to ask!
Course Gallery




Loading charts...