SlideShare a Scribd company logo
1 of 23
OOPs
Deepika p v v
Introduction
SystemVerilog provides an object-oriented class data abstraction.
- Objects can be dynamically created, deleted, assigned and accessed by
object handles
- Object handles provide a pointer-like mechanism
- OOP introduces the notion of a class, which is a collection of data and methods that is
dependent on object activity
Continued…
- Collection of interacting objects
a) class
b) object
c) Inheritance
d) polymorphism
class
● A Class defines a collection of Data members.
● Class contains variables referred as Class Properties.
● Classes contains Subroutines (Tasks/Functions) referred as Class Methods.
● Both Properties and Methods are treated as Members of the Class.
● Classes are constructed Dynamically to create Class Objects.
● A Class Variable stores Class Handle.
● A Class Objects are accessed via Class Handles.
● Class declaration does not occupy any memory, it only creates a new type.
Class Example
Class packet;
//properties
int a;
int pay;
//Methods
function new();
Return pay;
endfunction
endclass
Class packet;
//properties
int a;
int pay;
//Methods
function new(int a); //passing arguments
a =a; or this.a = a;
endfunction
endclass
Object Creation
● Every class has a built-in method called new()
which is must to call to create an object of that
class type.
● The new() method is also known as the
“constructor”
● Constructing an object allocates the space in the
memory needed to hold the properties of an object
● We can also define arguments to pass to the
constructor
,module top;
Class A;
task display();
$display(“AB”);
endtask
endtask
Initial begin
A h1; //A h1 = new();
h1 = new(); //object creation or instance
h1.display();
end endmodule
Null Object Handles
● Uninitialized object handles are set
to null by default
● Uninitialized objects are detected by
comparing the handle to null
● Accessing a property of
uninitialized objects results in a
runtime error
Module top;
Class packet;
Int count;
Endclass
Initial begin
Packet pkt;
If (pkt == null)
$display(“packet handle ‘pkt’ is null”);
$display(“count=%0d”, pkt.count);
End endmodule
Output : packet handle ‘pkt’ is null
Count ncsim : *E, TRNULLID : NULL point dereference
Continued…
module top;
Class A;
virtual function void display(); //with virtual
$display(“AB”);
Endtask
Endclass
Class B extends A;
task display();
$display(“CD”);
endtask endclass
Initial
Begin
A p;
B c;
c = new();
p = c;
c= null;
c.display();
p.display(); End
Endmodule
Continued…
(a) With virtual
h1.display();
O/P ?
(a) With virtual
h2.display();
O/P ?
C Without virtual
h1.display();
O/P ?
D Without virtual
h2.display();
O/P ?
Super
● The super keyword is used within a derived class to refer to
overridden members of parent class
Continued…
module top;
Class A;
int i;
function new(int i);
this.i = 20;
Endfunction endclass
Class B extends A;
int i;
function new(int i);
super.new(i);
this.i = i;
Endfunction endclass
initial begin
B b_h;
b_h = new(10);
$display(“%p”, b_h); p->20 c-> 10
end
endmodule
O/P : ?
Continued…
module top;
Class A;
int i;
function new(int i);
i = 20; //this.i = 20;
Endfunction endclass
Class B extends A;
int i;
function new(int i);
super.new(i);
this.i = i;
Endfunction endclass
initial begin
B b_h;
b_h = new(10);
$display(“%p”, b_h);
end
endmodule
O/P : ?
Continued…
module top;
Class A;
task display();
$display(“AB”);
Endtask
Endclass
Class B extends A;
task display();
$display(“CD”);
endtask endclass
Initial
Begin
A p;
B c;
p = new();
c = new();
p.display(); -> AB
c.display(); -> CD
End
Endmodule O/P ?
Continued…
module top;
Class A;
int i;
function new(int i=10);
this.i = i;
Endfunction endclass
Class B extends A;
int i;
function new();
i = 20;
Endfunction endclass
initial begin
B b_h;
b_h = new();
$display(“%p”, b_h);
end
endmodule
O/P : ?
Continued…
module top;
Class A;
int i;
function new(int i=10);
i = 10;
Endfunction endclass
Class B extends A;
int i;
function new();
i = 20;
Endfunction endclass
initial begin
B b_h;
b_h = new();
$display(“%p”, b_h);
end
Endmodule
O/P : ?
Polymorphism
A) It is an object-oriented programming language feature that allows a specific routine to use variables of
different types at different times
B) It is based on the concept that a base class pointer can be used to reference any of the derived class objects
Rules :
1. Parent and child methods should have the same name
2. Have to declare parent method as virtual, For child is not mandatory.
3. Have to do the assignment like p=c ((mandatory)
NOTE : Without assignment It cannot override the child methods and it will varry with the with & without
virtual keyword
Continued…
Module top;
Class A;
Virtual task display();
$display(“AB”);
Endtask
Endclass
Class B extends A;
Task display();
$display(“CD”);
Endtask
endclass
Initial
Begin
A p;
B c;
p = new();
c = new();
p = c;
with virtual
p.display(); -> CD
c.display(); -> CD
End
Endmodule
Continued…
(a) Without virtual
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
(a) With virtual
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
C Without virtual
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
D With virtual
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
Continued…
Module top;
Class A;
Virtual task display();
$display(“AB”);
Endtask
Endclass
Class B extends A;
Task display();
// super.new();
$display(“CD”);
Endtask endclass
Initial
Begin
A p;
B c;
p = new();
c = new();
p = c;
p.display();
c.display();
End
Endmodule
Continued…
(a) Without virtual
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
(a) With virtual
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
C Without virtual
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
D With virtual
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
Continued…
(a) Without virtual
super.new(); //In child class
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
(a) With virtual
super.new(); //In child class
h1 = new(); h2 = new();
h1.display(); h2.display();
O/P ?
C Without virtual
super.new(); //In child class
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
D With virtual
super.new(); //In child class
h1 = new(); h2 = new();
h1 = h2;
h1.display(); h2.display();
O/P ?
Continued...
● You have a class
- Decalred handles like p1 to p100
- Created instances for p1 to p5
- Now you have to calculate the how many instances are created without
counting
- Either implement a logic to calculate the how many instances created or is
there any other way to find ?
Thank you

More Related Content

Similar to oops.pptx

#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
arwholesalelors
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
ssuseraef9da
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
BackPack3
 

Similar to oops.pptx (20)

#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf#include algorithm #include vector #include iostream usi.pdf
#include algorithm #include vector #include iostream usi.pdf
 
Jeop game-final-review
Jeop game-final-reviewJeop game-final-review
Jeop game-final-review
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.ppt
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance Trivia
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

oops.pptx

  • 2. Introduction SystemVerilog provides an object-oriented class data abstraction. - Objects can be dynamically created, deleted, assigned and accessed by object handles - Object handles provide a pointer-like mechanism - OOP introduces the notion of a class, which is a collection of data and methods that is dependent on object activity
  • 3. Continued… - Collection of interacting objects a) class b) object c) Inheritance d) polymorphism
  • 4. class ● A Class defines a collection of Data members. ● Class contains variables referred as Class Properties. ● Classes contains Subroutines (Tasks/Functions) referred as Class Methods. ● Both Properties and Methods are treated as Members of the Class. ● Classes are constructed Dynamically to create Class Objects. ● A Class Variable stores Class Handle. ● A Class Objects are accessed via Class Handles. ● Class declaration does not occupy any memory, it only creates a new type.
  • 5. Class Example Class packet; //properties int a; int pay; //Methods function new(); Return pay; endfunction endclass Class packet; //properties int a; int pay; //Methods function new(int a); //passing arguments a =a; or this.a = a; endfunction endclass
  • 6. Object Creation ● Every class has a built-in method called new() which is must to call to create an object of that class type. ● The new() method is also known as the “constructor” ● Constructing an object allocates the space in the memory needed to hold the properties of an object ● We can also define arguments to pass to the constructor ,module top; Class A; task display(); $display(“AB”); endtask endtask Initial begin A h1; //A h1 = new(); h1 = new(); //object creation or instance h1.display(); end endmodule
  • 7. Null Object Handles ● Uninitialized object handles are set to null by default ● Uninitialized objects are detected by comparing the handle to null ● Accessing a property of uninitialized objects results in a runtime error Module top; Class packet; Int count; Endclass Initial begin Packet pkt; If (pkt == null) $display(“packet handle ‘pkt’ is null”); $display(“count=%0d”, pkt.count); End endmodule Output : packet handle ‘pkt’ is null Count ncsim : *E, TRNULLID : NULL point dereference
  • 8. Continued… module top; Class A; virtual function void display(); //with virtual $display(“AB”); Endtask Endclass Class B extends A; task display(); $display(“CD”); endtask endclass Initial Begin A p; B c; c = new(); p = c; c= null; c.display(); p.display(); End Endmodule
  • 9. Continued… (a) With virtual h1.display(); O/P ? (a) With virtual h2.display(); O/P ? C Without virtual h1.display(); O/P ? D Without virtual h2.display(); O/P ?
  • 10. Super ● The super keyword is used within a derived class to refer to overridden members of parent class
  • 11. Continued… module top; Class A; int i; function new(int i); this.i = 20; Endfunction endclass Class B extends A; int i; function new(int i); super.new(i); this.i = i; Endfunction endclass initial begin B b_h; b_h = new(10); $display(“%p”, b_h); p->20 c-> 10 end endmodule O/P : ?
  • 12. Continued… module top; Class A; int i; function new(int i); i = 20; //this.i = 20; Endfunction endclass Class B extends A; int i; function new(int i); super.new(i); this.i = i; Endfunction endclass initial begin B b_h; b_h = new(10); $display(“%p”, b_h); end endmodule O/P : ?
  • 13. Continued… module top; Class A; task display(); $display(“AB”); Endtask Endclass Class B extends A; task display(); $display(“CD”); endtask endclass Initial Begin A p; B c; p = new(); c = new(); p.display(); -> AB c.display(); -> CD End Endmodule O/P ?
  • 14. Continued… module top; Class A; int i; function new(int i=10); this.i = i; Endfunction endclass Class B extends A; int i; function new(); i = 20; Endfunction endclass initial begin B b_h; b_h = new(); $display(“%p”, b_h); end endmodule O/P : ?
  • 15. Continued… module top; Class A; int i; function new(int i=10); i = 10; Endfunction endclass Class B extends A; int i; function new(); i = 20; Endfunction endclass initial begin B b_h; b_h = new(); $display(“%p”, b_h); end Endmodule O/P : ?
  • 16. Polymorphism A) It is an object-oriented programming language feature that allows a specific routine to use variables of different types at different times B) It is based on the concept that a base class pointer can be used to reference any of the derived class objects Rules : 1. Parent and child methods should have the same name 2. Have to declare parent method as virtual, For child is not mandatory. 3. Have to do the assignment like p=c ((mandatory) NOTE : Without assignment It cannot override the child methods and it will varry with the with & without virtual keyword
  • 17. Continued… Module top; Class A; Virtual task display(); $display(“AB”); Endtask Endclass Class B extends A; Task display(); $display(“CD”); Endtask endclass Initial Begin A p; B c; p = new(); c = new(); p = c; with virtual p.display(); -> CD c.display(); -> CD End Endmodule
  • 18. Continued… (a) Without virtual h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? (a) With virtual h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? C Without virtual h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ? D With virtual h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ?
  • 19. Continued… Module top; Class A; Virtual task display(); $display(“AB”); Endtask Endclass Class B extends A; Task display(); // super.new(); $display(“CD”); Endtask endclass Initial Begin A p; B c; p = new(); c = new(); p = c; p.display(); c.display(); End Endmodule
  • 20. Continued… (a) Without virtual h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? (a) With virtual h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? C Without virtual h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ? D With virtual h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ?
  • 21. Continued… (a) Without virtual super.new(); //In child class h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? (a) With virtual super.new(); //In child class h1 = new(); h2 = new(); h1.display(); h2.display(); O/P ? C Without virtual super.new(); //In child class h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ? D With virtual super.new(); //In child class h1 = new(); h2 = new(); h1 = h2; h1.display(); h2.display(); O/P ?
  • 22. Continued... ● You have a class - Decalred handles like p1 to p100 - Created instances for p1 to p5 - Now you have to calculate the how many instances are created without counting - Either implement a logic to calculate the how many instances created or is there any other way to find ?