Answers for "define instantiation in oop"

1

What is instantiation OOP?

It is the creation of a new instance of an object, with respect to OOP.

Suppose we have a programming class called “Dog”. To instantiate this class we create a new object of type Dog. We would do something like this:

// this is instantiation 
Dog myDog = new Dog(); 
// set properties of the dog 
myDog.setName(“Fido”); 
myDog.setAge(3); 
myDog.setBreed(“Airedale”); 
// other instantiation methods, if the constructor is overloaded 
Dog bigDog = new Dog(“Rover”, 4, “Great Dane”);
Posted by: Guest on May-20-2021

Browse Popular Code Answers by Language