What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm that focuses on objects and their interactions.
What are the four main concepts of OOP?
Encapsulation, abstraction, inheritance, and polymorphism.
What is a class?
A class is a blueprint for creating objects.
What is an object?
An object is an instance of a class.
What are the properties of a class?
The properties of a class are the variables that define the object's state.
What are the methods of a class?
The methods of a class are the functions that define the object's behavior.
What is encapsulation?
Encapsulation is the practice of hiding the internal details of an object from the outside world.
How is encapsulation achieved?
Encapsulation is achieved through access modifiers such as public, private, and protected.
What is abstraction?
Abstraction is the practice of simplifying complex systems by breaking them down into smaller, more manageable parts.
How is abstraction achieved?
Abstraction is achieved through abstract classes and interfaces.
What is inheritance?
Inheritance is the process by which one class inherits the properties and methods of another class.
What is a base class?
A base class is the class that is being inherited from.
What is a derived class?
A derived class is the class that is inheriting.
What are the types of inheritance?
Single inheritance, multiple inheritance, and hierarchical inheritance.
What is polymorphism?
Polymorphism is the ability of an object to take on many forms.
How is polymorphism achieved?
Polymorphism is achieved through method overriding and method overloading.
What is method overriding?
Method overriding is the process of replacing a method in the base class with a new implementation in the derived class.
What is method overloading?
Method overloading is the process of creating multiple methods with the same name but different parameters.
What are virtual functions?
Virtual functions are functions that are declared in a base class and can be overridden in a derived class.
What are abstract classes?
Abstract classes are classes that cannot be instantiated and contain one or more abstract methods.
What are interfaces?
Interfaces are similar to abstract classes but they only contain abstract methods and no implementation.
What is a constructor?
A constructor is a special method that is called when an object is created.
What is the purpose of a constructor?
The purpose of a constructor is to initialize the object's state.
What is a destructor?
A destructor is a special method that is called when an object is destroyed.
What is the purpose of a destructor?
The purpose of a destructor is to free up any resources that the object was using.
What is a static method?
A static method is a method that belongs to the class and not to any instance of the class.
What is the purpose of a static method?
The purpose of a static method is to perform a task that is not dependent on any particular instance of the class.
What is a static variable?
A static variable is a variable that belongs to the class and not to any instance of the class.
What is the purpose of a static variable?
The purpose of a static variable is to share data across all instances of the class.
What is a constructor in a class?
A constructor is a special method that is called when an object is created from a class. It is used to initialize the object's properties and set their initial values.
What is an access modifier in a class?
An access modifier is a keyword that determines the level of access to a class member (property or method). There are three types of access modifiers in C#: public, private, and protected.
What is the difference between a public and a private access modifier?
A public access modifier allows the member to be accessed from anywhere, while a private access modifier restricts the member to be accessed only within the class.
What is a derived class in inheritance?
A derived class is a class that inherits properties and methods from a parent (base) class. It adds its own properties and methods, and may override some of the inherited methods.
What is multiple inheritance?
Multiple inheritance is a feature of some programming languages, such as C++, where a derived class can inherit properties and methods from multiple base classes.
What is method overloading in polymorphism?
Method overloading is when multiple methods with the same name but different parameters are defined in a class. The correct method to use is chosen based on the arguments used when calling the method.
What is method overriding in polymorphism?
Method overriding is when a derived class provides its own implementation of a method that is already defined in the base class. The method in the derived class has the same name, return type, and parameters as the method in the base class.
What is a virtual function in polymorphism?
A virtual function is a method in a base class that can be overridden by a method in a derived class. It allows the correct method to be called at runtime based on the type of the object.
What is an abstract class in OOP?
An abstract class is a class that cannot be instantiated and is used as a base class for other classes. It can define abstract methods, which must be implemented by its derived classes.
What is an interface in OOP?
An interface is a blueprint for a set of methods and properties that a class must implement. It defines the contract that a class must adhere to in order to be used in a certain way.
What is the difference between an abstract class and an interface?
An abstract class can have method implementations, while an interface can only define method signatures. A class can inherit from only one abstract class, but can implement multiple interfaces.
What is a final method?
A final method is a method in a class that cannot be overridden by any subclass. Once a method is marked as final, it cannot be modified by any subclass. This is useful when the behavior of a method is critical and should not be changed, or when a method is intended to be used as is, without modification.