Home System Verilog Interview Questions SV OOP
Main Menu
System Verilog
    - Constructs
    - SV Classes
    - Functional Coverage SV
    - Examples
    - Tools
    - Links
    - Books
    - Interview Questions SV
        -- What is callback
        -- What is factory pattern
        -- Logic Reg wire
        -- Need Clocking Block
        -- Ways to avoid race
        -- Coverage Questions
        -- OOP
        -- Need of virtual interface
        -- abstract class
        -- Part 1
        -- Part 2
Open Vera
Digital Concepts
Verification Basics
Interview Questions
Computer Architechture
C and C++
AsicGuru Blog
Tags Cloud
Usefull Sites
Know Your IP/Location
Local Information India
Buy Car/Inverter Batteries
Real Estate India
Sports Accessories India
What is object oriented programming
Share This Articale:

What is object oriented programming :

OOP Can be described with following concepts :

  • Follows bottom up approach.
  • Emphasis is on data.
  • Programs are divided into objects.
  • Functions and data are bound together.
  • Communication is done through objects.
  • Data is hidden.

The following are the basic concepts of OOPs:
Classes, Objects, Data abstraction and encapsulation, Polymorphism, Inheritance, Message Passing, and Dynamic Binding.

Q. What is a class?
Class is an entity which consists of member data and member functions which operate on the member data bound together.

Q. What is an object?
Objects are instances of classes. Class is a collection of similar kind of objects. When a class is created it doesn’t occupy any memory, but when instances of class is created i.e., when objects are created they occupy memory space.

Q. What is encapsulation?
A1. Encapsulation is welding of code and data together into objects.

Q. What is inheritance?
A2. Inheritance is a mechanism through which a subclass inherits the properties and behavior of its superclass. The derived
class inherits the properties and method implementations of the base class and extends it by overriding methods and adding additional properties and methods.

 Q. What is polymorphism?
A3. In Greek this means "many shapes."As a consequence of inheritance and virtual functions, a single task (for example, drawing
a geometrical shape) can be implemented using the same name (like draw()) and implemented differently (via virtual functions) as each type in object hierarchy requires(circle.draw() or rectangle.draw()). Later, when a polymorphic  object (whose type is not known at compile time) executes the draw() virtual function, the correct implementation is chosen andexecuted at run time.

Q. What is the difference between function overloading and function overriding?
A. Overloading is a method that allows defining multiple member functions with the same name but different signatures. The compiler will pick the correct function based on the signature. Overriding is a method that allows the derived class to redefine the behavior of member functions which the derived class inherits from a base class. The signatures of both base class member function and derived class member function are the same; however, the implementation and, therefore, the behavior will differ

Q. What are the advantages of OOP?

  • Data hiding helps create secure programs.
  • Redundant code can be avoided by using inheritance.
  • Multiple instances of objects can be created.
  • Work can be divided easily based on objects.
  • Inheritance helps to save time and cost.
  • Easy upgrading of systems is possible using object oriented systems.
Q. Explain about the virtual task and methods .

Virtual tasks and functions are the ways to achieve the polymorphism in system verilog. Try to fun the following example and see it will help you understand the concept.

class base ;

    virtual function int print;
        $display("INSIDE BASE \n");
    endfunction : print

endclass : base

class derived extends base;

    function int print;
        $display("INSIDE DERIVED \n");
    endfunction : print

endclass : derived

program test ;

    derived d1;
        d1 = new();
        callPrint (d1);

    task callPrint (base b1);
        $display("Inside callPrint \n");
    endtask : callPrint


Output :

VSIM 1> run
# Inside callPrint

Keywords : class   encapsulation   inheritance   oop   polymorphism  

This Articles is written/submitted by puneet (Puneet Aggarwal). You can also contribute to Asicguru.com. Click here to start

Prev << Coverage Questions

Next >> Need of virtual interface

Sign In
Login with :-
| | |  
  • Bookmark