Dynamic binding, also known as late binding, refers to the process where method calls are resolved at runtime based on the actual object type. This allows for more flexible and dynamic method invocations.
Which of the following allows multiple methods to have the same name but different signatures?
A Method Overloading
B Method Overriding
C Method Inheritance
D Method Cloning
Method overloading allows multiple methods with the same name but different parameter types or numbers to exist within the same class. This provides flexibility in how methods are called depending on the input.
What is the key difference between Method Overloading and Method Overriding?
A Object vs class
B Compile-time vs runtime
C Same class, same signature
D Different classes
Method overloading happens at compile-time and allows methods to have the same name but different parameters. Method overriding happens at runtime, where a subclass provides a specific implementation of a superclass method.
What is the purpose of an Abstract Class in OOP?
A To instantiate objects
B To hide data
C To provide a blueprint
D To implement interfaces
An abstract class cannot be instantiated directly and is used to define a blueprint for other classes. It allows subclasses to inherit common attributes and methods, while still enforcing specific method implementations.
Which of the following cannot be defined in an Interface in OOP?
A Concrete methods
B Static methods
C Constants
D Abstract methods
An interface defines only abstract methods (without implementation). It cannot contain concrete methods. Any class implementing the interface must provide implementations for the abstract methods defined in the interface.
What is the purpose of Static Binding in OOP?
A Method overriding
B Object initialization
C Resolving methods at runtime
D Resolving methods at compile time
Static binding occurs during compile-time, where the method to be called is determined by the method signature. It is faster than dynamic binding but lacks flexibility since it is fixed before runtime.
Which of the following is a feature of Interfaces in OOP?
A Cannot inherit methods
B Can be instantiated
C Can implement multiple classes
D Can have constructors
Interfaces allow a class to implement multiple interfaces. Unlike classes, interfaces provide a way to enforce a contract for methods that classes must follow, without providing method implementations themselves.
Which concept in OOP allows a subclass to define its version of a method already defined in its superclass?
A Abstraction
B Method Overriding
C Method Overloading
D Inheritance
Method overriding allows a subclass to provide its specific implementation of a method that is already defined in its superclass. It helps in customizing or enhancing inherited behavior.
What is the significance of Abstract Methods in OOP?
A To enforce method implementation
B To provide code reuse
C To hide class details
D To support multiple inheritance
Abstract methods are methods declared in an abstract class or interface with no implementation. They force subclasses to provide concrete implementations, ensuring that certain methods are always defined in derived classes.
Which of the following is a valid characteristic of an Interface?
A Can include constructor methods
B Method definition with implementation
C Multiple inheritance support
D Can be instantiated directly
Interfaces support multiple inheritance, allowing a class to implement more than one interface. Unlike classes, interfaces can be used to define behaviors that are shared across different classes.
Which OOP principle ensures that a class has only one instance throughout the system?
A Factory Pattern
B Observer Pattern
C Singleton Pattern
D Proxy Pattern
The Singleton design pattern ensures that a class has only one instance throughout the program and provides a global point of access to that instance. This is particularly useful for shared resources like database connections.
What is the main function of Method Overriding in OOP?
A To manage object states
B To change inherited behavior
C To increase performance
D To improve code readability
Method overriding allows a subclass to provide a specific implementation of a method that it inherits from a superclass. This helps modify or extend the behavior of the inherited method to meet its requirements.
Which of the following best defines Polymorphism in OOP?
A Same method, different behavior
B Combining methods
C Inheriting behavior
D Different method, same name
Polymorphism allows a method to have different behaviors based on the object invoking it. This can be achieved through method overriding or dynamic method dispatch, allowing flexibility in method invocation.
What happens when an object implements an interface?
A The object provides method definitions
B The object can inherit methods
C The object can use constructors
D The object must define the interface methods
When a class implements an interface, it must provide concrete implementations for all the methods declared in the interface. This enforces a contract that ensures the class follows the interface’s method signatures.
Which of the following is an example of Method Overloading?
A Changing the method signature in a subclass
B Implementing abstract methods
C Defining methods with the same name but different parameters
D Overriding inherited methods
Method overloading allows multiple methods with the same name to coexist in a class, as long as their parameter lists differ (in type, number, or both). This allows a method to be used for different input scenarios.