What is OOPS?
It is a programming language model organized around objects rather than "actions" and data rather than logic.
Programming approach that provided modularity means both data_members (attributes) and methods (function or task) can be used as templates for creating copies of such modules on demand.
What are the Basic Concepts of OOPs?
What is an object?
Object is an instance of a class that is created dynamically.
What is Abstraction?
Users just need to give appropriate arguments to the method while using it, internal complexity or background process is not shown to users. They get the result what they want.
Since class is a concept of data abstraction, it is known as abstract data type (ADT).
What is Encapsulation?
The wrapping up of data & methods into a single unit (called class) is known as encapsulation. Here class acts like a container.
These methods provide interface between program and object/class’s data. The insulation of data from direct access by the program is called data hiding. (Keep in mind that all data_member are declared as private)
What is Inheritance?
In SystemVerilog this is achieved by using extends keyword.
What is multiple inheritance?
Systemverilog doesn’t support multiple inheritance. To overcome this problem it allows to implement multiple interface-class.
Is it possible for a class to inherit the constructor of its base class?
Can you call a base class method without creating instance?
- It’s possible if it’s a static method.
- It’s possible if you derive the class from base class then take instance of derived class when call method by using derived class’s instance.
- It’s possible from derived classes using keyword “super”.
What is polymorphism?
In systemverilog there are two types of polymorphism:
- Compile time polymorphism (overloading) and
- Runtime polymorphism (overriding).
When a class has more than one method with same name but different parameters, then we call those methods are overloaded.
Overloaded methods can be either static or non-static.
However System Verilog doesn't support Method Overloading (except constructor).
Language feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super class or parent class.
Actual method which will be called is determined by the type of object at run-time.
Static methods cannot be overridden.
Two virtual methods must have the same signature.
What are the rules to be followed while overriding a method?
- Name of the method must be same,
- Return type of method must be same,
- Parameter list of a method must be same,
- Must not reduce the visibility.
What is method signature? What are the things it consists of?
- Method name
- Number of arguments
- Types of arguments
Virtual vs pure_virtual?
Pure virtual: If you forgot to override method in child class then at compile-time error will be shouted. So, you will come to know that you forgot to override that particular method in child class. This will stop unexpected behavior of code.
Pure virtual method is also called as abstract method.
What is abstract class?
Abstract classes are those which can be used for creation of handles. However their methods and constructors can be used by the child or extended class. The need for abstract classes is that you can generalize the super class from which child classes can share its methods.
A class is called abstract class if it is only used as a super-class for other classes.
Derived classes must define the properties of abstract class.
Abstract classes cannot be instantiated.
The subclass of an abstract class which can create an object is called as "concrete class".
Explain the concept of constructor?Constructor is a special method of a class, which is called automatically when the instance of a class is created. It is created with the same name as the class and initializes all class members, whenever you access the class. The main features of a constructor are as follows:
- Constructors do not have any return type.
- Constructors can be overloaded.
- It is not mandatory to declare a constructor; it is invoked automatically.