473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

What are your thoughts on Java inheritance?

7 Nibble
Which changes do I need to make to the code below in order for a.f2(); to work?

Expand|Select|Wrap|Line Numbers
  1. public class A {
  2.   void f1(){}   
  3. }
  4.  
  5. public class B extends A {
  6.   void f2(){}
  7. }
  8.  
  9. void main(String[] args) {
  10.   A a =  ...     <- free space here
  11.   a.f1();
  12. }
I've been asked to change the way I added void f2(){} to class A.

No additional free space was included in this code.
I went through some resources but didn't get it.
Jan 16 '23 #1

✓ answered by cetpainfotech

Inheritance is a fundamental concept in object-oriented programming, and Java fully supports it. Inheritance allows a class to inherit properties and methods from a parent class, which can greatly simplify code reuse and organization. However, it is important to use inheritance judiciously and not overuse it, as it can lead to complex and difficult-to-maintain code if not used correctly. Additionally, Java also supports interfaces, which allow for a form of polymorphism called "interface polymorphism" which is also a powerful technique for code reuse and organization.

2 6502
cetpainfotech
15 Byte
Inheritance is a fundamental concept in object-oriented programming, and Java fully supports it. Inheritance allows a class to inherit properties and methods from a parent class, which can greatly simplify code reuse and organization. However, it is important to use inheritance judiciously and not overuse it, as it can lead to complex and difficult-to-maintain code if not used correctly. Additionally, Java also supports interfaces, which allow for a form of polymorphism called "interface polymorphism" which is also a powerful technique for code reuse and organization.
Jan 27 '23 #2
pritikumari
23 16bit
According to my thoughts inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current*class*also.

Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented programming*system).

Inheritance represents the IS-A relationship which is also known as a parent-child*relationship.

The most important use of inheritance in Java is code reusability. The code that is present in the parent class can be directly used by the child class. Method overriding is also known as runtime polymorphism. Hence, we can achieve Polymorphism in Java with the help*of*inheritance.
Jan 28 '23 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rajan | last post by:
Hi All C++ Experts Can anybody share some of your thoughts in Member Function Templates implementation.Can you also give some example on it Best Regards Raj
2
by: Joe_Black | last post by:
Hi all, I have an app that I want to have activation codes for, it has plugin dll files each of which have an activation code as well. I need to generate a unique code that is specific to the...
5
by: VB Programmer | last post by:
First time I've heard of it... http://www.microsoft.com/products/expression/en/default.mspx Will this be a replacement for VS.NET or Frontpage? How does this technology fit in? Is the...
4
by: james | last post by:
Hi I am in the process of developing a simple web-downloadable application to be run on multiple users machines. Your thoughts would be appreciated as to whether VB6 or C#.net would be the...
5
by: sreekalavinu | last post by:
I wish to include a search engine within my website.please give your thoughts
13
Dököll
by: Dököll | last post by:
Hey gang! We have about 350 working database, perhaps more. The IS Unit Dir. has, thus far, converted a number of extremely important databases to Java, he's very intelligent. I was also...
1
Stang02GT
by: Stang02GT | last post by:
Hello, I'm looking for your thoughts, ideas, and suggestions on this situation. I have recently been given the task to "fix" a menu within the companies intranet site. The current menu...
0
by: JoeyD | last post by:
One of the groups that we support has proposed to us what they like to see for a H/A SQL configuration. They want to use an existing SQL Server 2000 Failover Cluster (which we would have to...
0
by: Suganya | last post by:
"Change your language and you change your thoughts." Learn English and free download Grammar & dictionary. Just click the website and share ur thoughts….enter in the search column “What do u...
0
Niheel
by: Niheel | last post by:
What are your thoughts on Google's addition of PHP to app engine? Smart (with it's abundance of developers and applications)? or a step back for web development languages? Google App Engine adds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.