What is instantiation OOP?

Instantiation means you creating an object of that class.

There are some cases where you don’t want that your class’ instance will be created.

Now, you may have doubt that Why do I don’t want to create an object of that class?

So here are some reasons:

A class contains only static methods or it is final. i.e. Math class in Java
A class contains an abstract method(s) which means implementation of the method 
is not done. Now if you don’t have any implementation(logic) is done then there 
is no meaning of using that method. So If you create an object and then call 
that method. It is useless. That’s why it is not possible to instantiate an 
abstract class.

3.33
9
Grimolatto 130 points

                                    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”);

3.33 (9 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source