UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Base obj=new Child(); What are the advantage and real life application of above code?

Asked by Last Modified  

25 Answers

Learn Java

Follow 1
Answer

Please enter your answer

Java Trainer

Have you ever observed while communicating with databases? You can find such type of example while writing code from communicating with DB. Connection connectionObject = DriverManager.getConnection(); or Statement simpleStatement = connectionObject.getStatement(); The value of the connectionObject...
read more
Have you ever observed while communicating with databases? You can find such type of example while writing code from communicating with DB. Connection connectionObject = DriverManager.getConnection(); or Statement simpleStatement = connectionObject.getStatement(); The value of the connectionObject variable depends on the database driver you are using (most of the time you load the driver with Class.forName("some driver implementaion")). The answer for your question is, such type of coding helps you to implement and use your own mechanism that suits to your requirements / circumstances. read less
Comments

Tutor

1.It is basis of Polymorphism. 2. Lets say you have a parent class called Animal and child classes called Dog, Cat, and Lizard. Each class has a method call makeSound(). Then when you say Animal a1 = new Dog(); and Animal a2 = new Cat(), a1.makeSound() will bark and a2.makeSound() will meow. The...
read more
1.It is basis of Polymorphism. 2. Lets say you have a parent class called Animal and child classes called Dog, Cat, and Lizard. Each class has a method call makeSound(). Then when you say Animal a1 = new Dog(); and Animal a2 = new Cat(), a1.makeSound() will bark and a2.makeSound() will meow. The technical term for this behavior is called polymorphism. It is useful for code reuse. You only need to write code once for an application that has Animals makeSound() when they are happy, instead of separate code for each animal type. 3.Another use of polymorphism is hiding your code's implementation from other users. For example you can show other users that you are using a List and then you have the choice to implement the List as a LinkedList or as an ArrayList. You can also choose a LinkedList and then at a later time switch to an ArrayList without effecting your users. You also can't say Dog d = new Animal() because a Dog is an Animal but an Animal is not necessarily a Dog. read less
Comments

Industry expert and professional lecturer/trainer

Dynamic Polymorphism which promotes calling only those methods which parent is aware of. Mostly used in API creation.
Comments

You can get all the attributes and behavior of a class by creating its object.
Comments

Best Training institute for Both Technical and Non Technical domians

This is the most fundamental use of polymorphism because using a parent class reference to refer to a child object is what allows you to take advantage of the benefits of polymorphism. Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs...
read more
This is the most fundamental use of polymorphism because using a parent class reference to refer to a child object is what allows you to take advantage of the benefits of polymorphism. Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. read less
Comments

Software Professional Trainer with 26+ years of Experience in Software Design and Development

It dynamic polymorphism, where derived class object is assigned to Base class object. Whenever you want to do late binding you can use this concept.
Comments

Software Professional with 14 years experience - Mentoring & Training Students & Professionals

Polymorphishm is the advantage of the above code. Say you have animal class with animal reference you can create object of a cat or a dog. So in run time it differentiates. For example Animal a = new Cat(); (if cat extends animal) a = new Dog()(if dog extends animal) so same reference a can hold objects...
read more
Polymorphishm is the advantage of the above code. Say you have animal class with animal reference you can create object of a cat or a dog. So in run time it differentiates. For example Animal a = new Cat(); (if cat extends animal) a = new Dog()(if dog extends animal) so same reference a can hold objects of cat and dog as both inherites animal read less
Comments

Let's simplify Coding, It's a great Fun.

Hi, The above code is using the parent reference type to point to child object. Now from the obj reference you can point to all the members of base class as well as to the child class (by type casting). This is the normal practice in java technologies to create the parent reference type for child...
read more
Hi, The above code is using the parent reference type to point to child object. Now from the obj reference you can point to all the members of base class as well as to the child class (by type casting). This is the normal practice in java technologies to create the parent reference type for child objects, this strategy enables your code flexible for any sub-child, for example, if you have a method like this add(Collection c), this means parameter can be object of List,Set or any sub-collection object, this makes your method more generic & powerful. regards vijay read less
Comments

This is the basis for polymorphism: Imagine you have several child classes that inherit from you parent class. You want to use all these child classes through the interface / methods defined on your parent class, without worrying about the implementation details in each child class (each might do something...
read more
This is the basis for polymorphism: Imagine you have several child classes that inherit from you parent class. You want to use all these child classes through the interface / methods defined on your parent class, without worrying about the implementation details in each child class (each might do something different, but with the same overall semantics). This is possible because the child class has a IS A relationship with its parent class since child inherits from parent. read less
Comments

Java/J2EE/SFDC Corporate Trainer

This is actually dynamic binding, depending upon demand the memory will be created for respective object.
Comments

View 23 more Answers

Related Questions

How do I learn Java? From book or internet or a coaching?
It is good to learn Java from Coaching where you will get more exposure in learning at faster pace.
Suresh
0 0
7

I am a fresher and I want to become a Java developer, so what is necessary to crack the Java interview ? 

For an interview, you should prepare all the basic questions of Java , class, function and OOP concepts.
Dipesh

Hi every one i have done my I com so plzz suggest me it course. I want do carrer in it field

First of all you should take the degree course with full concept because when you have chosen this subject then you will haveto try for best performance in it
Aquib
0 0
9
What is the difference between Java SE, ME, EE?
Java SE is Standard Edition of Java, also known as Core Java. Anybody who wants to work with Java must learn this. And, this is used to write stand alone software with Java. . Java ME is the Micro Edition...
Sense Softech
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

What Is Applet & Its Life Cycle?
What is Applet & its life cycle?Applet is a Java programme that can be embedded into HTML page.Java Applet runs on the java enables web browsers such as Mozilla & Internet Explorer.Applets are...
I

ICreative Solution

0 0
0

Programing Languages Learning Tricks
You want to learn that new language or library or framework as soon as possible, right? That’s understandable. Fortunately, there are a handful of tips that can help you to better retain all of that...

Harshal G.

0 0
0

Java Interview Questions & Answers
Java Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Java Programming Language. As per my...

Comparable vs Comparator
java.lang.Comparable java.util.Comparator For comparing some other object with its own object. Ex. I am comparing myself to some other employee. Method signature is: int compareTo (T object). For...

Why Should We Learn Java Language?
Most of starters has confusion today that which of the programming language should be chosen to work on. It totally depends upon your need. As per my opinion, if you want to grow your career in IT industry...

Recommended Articles

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more