Write a java program that uses inheritance to extend box. Use the extend keyword to include weight.
// use the super keyword to access the variables
//of the parent class, remember that only weight(m)
//was declared in this class but the other three
//were declared in the parent class so to access them
//you must use the super keyword otherwise the
//compiler will generate an error.

Recommended Answers

All 6 Replies

First you to make a parent class where you declare all the instance variables, methods, etc..all what is needed. In the subclass of the parent class you have to include an extend keyword..For example if you a parent class, public class Figures and wanted to create a subclass from that it should be.. public class Square extends Figures..the class square can inherit the attributes and methods of the parent class Figures..you can also add methods, etc..

First you to make a parent class where you declare all the instance variables, methods, etc..all what is needed. In the subclass of the parent class you have to include an extend keyword..For example if you a parent class, public class Figures and wanted to create a subclass from that it should be.. public class Square extends Figures..the class square can inherit the attributes and methods of the parent class Figures..you can also add methods, etc..

can you make a program for it? pls....badly needed,, im still not familiar with java.. can you help me?

No, we won't write it for you. That is not helping you. You don't learn anything that way. And, if you're not going to learn anything, there is no need to take the class, and you definately should not pass it, if you don't learn anything.

And you should be thankful that glowkazaf told you how to do it in the first place even though the way you asked for help was rude. If you opened a Java book you would have found out that what you are being asked to do is the simplest thing in inheritance

can you make a program for it? pls....badly needed,, im still not familiar with java.. can you help me?

And obviously the whole point of the assignment is for you to get familiar with Java - so make an effort.

good answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.