Inheritance Example 3- Room - Java

Program:
class Room
{
   int length,width;
   Room(int a,int b)
   {
     length = a;
     width = b;
   }
   void area()
   {
     int area = length*width;
     System.out.println("The area of the room is " +area);
   }
}

class roomvol extends Room
{
   int height;
   roomvol(int a,int b,int c)
   {
     super(a,b);
     height = c;
   }
   void volume()
   {
     int volume = length*width*height;
     System.out.println("The volume of the room is " +volume);
   }
}

class inheritance3
{
   public static void main(String args[])
   {
     roomvol room2 = new roomvol(10,40,20);
     room2.area();
     room2.volume();
   }
}

Output:
nn@linuxmint ~ $ javac inheritance3.java
nn@linuxmint ~ $ java inheritance3
The area of the room is 400
The volume of the room is 8000
nn@linuxmint ~ $

51 comments:

  1. It is really a great work and the way in which u r sharing the knowledge is excellent.Thanks for helping me to understand basic concepts. As a beginner in java programming your post help me a lot.Thanks for your informative article.java training in chennai | chennai's no.1 java training in chennai

    ReplyDelete
  2. nice blog. thanks for sharing valuable information. It’s really good.Any one looking software courses nareshit is the best offline and online software training institute in Hyderabad and Chennai.

    ReplyDelete
  3. Good work sir, Thanks for the proper explanation about Inheritance . I found one of the good resource related JAVA and OOPS concepts. It is providing in-depth knowledge on JAVA and OOPS. which I am sharing a link with you where you can get more clear on JAVA and OOPS. To know more Just have a look at this link

    Java Tutorial
    Class and object
    Inheritance
    Polymorphism
    Abstraction
    Encapsulation

    ReplyDelete
  4. Linux Online training in India – Webtrackker Technology is providing the linux online training with 100% placement support. If you are looking for the BEST LINUX & UNIX Training Institute In india or linux online training from india, live project based LINUX & UNIX online training then you can contact to us.

    Python online training in India, RPA Online training in India, Salesforce online training in india, AWS online training in india, Cloud Computing Online Training in India, SAS Online Training in india, Hadoop online training in INDIA, Oracle DBA online training in India, SAP online Training In india, Linux Online training in India








    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. 6-week summer course in Noida - 6 weeks The summer course plays a crucial role in shaping the career of young aspiring / informatics students. This training has been specifically introduced so that students can become familiar with current industrial culture and industrial needs. Webtrackker technology offers a 6-month training program for students / graduates that includes small and large projects.
    6-week summer course in Noida

    ReplyDelete
  8. Each department of CAD have specific programmes which, while completed could provide you with a recognisable qualification that could assist you get a job in anything design enterprise which you would really like.

    AutoCAD training in Noida

    AutoCAD training institute in Noida


    Best AutoCAD training institute in Noida

    ReplyDelete
  9. Video editing course in Noida
    Video editing training institute in Noida- Webtrackker Technology is and IT Training institute providing the Video editing course in Noida, FCP, Final Cut Pro Training in Noida. For more call us- 8802820025.
    Video editing course in Noida
    Company Address:
    Webtrackker Technology
    C- 67, Sector- 63, Noida
    Phone: 01204330760, 8802820025
    Email: info@webtrackker.com
    Website: http://webtrackker.com/Best-training-institute-Video-editing-FCP-course-in-Noida.php

    ReplyDelete
  10. Cloud Computing Training In Noida
    Webtrackker is IT based company in many countries. Webtrackker will provide you a real time projects based training on Cloud Computing. If you are looking for the Cloud computing training in Noida then you can join the webtrackker technology.
    Cloud Computing Training In Noida , Cloud Computing Training center In Noida , Cloud Computing Training institute In Noida ,

    Company Address:
    Webtrackker Technology
    C- 67, Sector- 63, Noida
    Email: info@webtrackker.com
    Website: www.webtrackker.com
    http://webtrackker.com/Cloud-Computing-Training-Institutes-In-Noida.php

    ReplyDelete
  11. I am really happy with your blog because your article is very unique and powerful for new reader.
    Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune

    ReplyDelete
  12. Good article.Thank you for sharing this blog please visit our website.
    ServiceNow Training in Hyderabad

    ReplyDelete
  13. Best Java training Institute in Ahmedabad, Java courses curated by Industry Expert, Java programming classes with Hands on Real-time Project & 100% Job assistance.
    Advanced Java training in Ahmedabad

    ReplyDelete
  14. click here for more information about the latest stuff oneplus c type jack

    ReplyDelete
  15. Like different elements of India, numerous oil and spices usually cross into making food. This effects in substances getting caught to the partitions of the filter out.
    Visit here
    http://kitchenware.ml
    Best kitchen chimney installation and service
    Auto clean chimney sevice in Faridabad

    ReplyDelete
  16. I found this post interesting and worth reading. Thanks for sharing!!
    DevOps Online Training

    ReplyDelete
  17. Certainly this information might be worthwhile and advantageous for numerous apprentices who are learning java. Keep up with this admirable work and continue sharing. Professional Web design services are provided by W3BMINDS- Website designer in Lucknow.
    Web development Company | Web design company

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. I am very happy when this blog post read because blog post written in good manner and write on good topic.
    Thanks for sharing valuable information
    Java Training Institute in Noida

    ReplyDelete
  20. Thank you so much for posting this. I really appreciate your work. Keep it up. Great work!

    CEH Training In Hyderbad

    ReplyDelete

  21. Thank you for sharing such great information very useful to us.
    Java Training in Noida

    ReplyDelete
  22. Discount hotels deal online

    Hotels - Find the low-cost last minute hotels deals package on AirlineDeals.net. We offer the best discount hotels deal online. Book your last minute hotels deals package.

    to get more - https://airlinedeals.net/hotels/

    ReplyDelete
  23. A model is a person with a function either to sell, show or market it industrial products (appreciably style garb in style indicates), or to serve as a visual useful resource for individuals who are creating works of artwork or to pose for images +919910294610.
    Whatsapp number - 9910294610
    Arvind Rawat model in Noida
    Visit here
    Arvind Rawat Model in Noida
    Arvind Rawat Model in Noida

    ReplyDelete
  24. Best kitchen chimney installation and service in NCR
    When cooking with oil, you will see the fact that smoke usually receives emitted in case you often uses the identical oil. Typically, these form of eating places have today's hoods as well as exhaust fans.
    Visit here
    Kitchen Chimney Repair Service in Noida
    Kitchen Kitchen Chimney Repair Service in Vaishali
    Kitchen Kitchen Chimney Repair Service in indirapuram
    Kitchen Kitchen Chimney Repair Service in vasundhra
    Kitchen Kitchen Chimney Repair Service in faridabad


    url
    http://kitchenware.ml/home/kitchen-chimney-repair-service-in-noida
    http://kitchenware.ml/kitchen-chimney-repair-service-in-vaishali
    http://kitchenware.ml/kitchen-chimney-repair-service-in-indirapuram
    http://kitchenware.ml/kitchen-chimney-repair-service-in-vasundhra–
    http://kitchenware.ml/kitchen-chimney-repair-service-in-faridabad

    ReplyDelete
  25. When cooking with oil, you will see the fact that smoke usually receives emitted in case you often uses the identical oil. Typically, these form of eating places have today's hoods as well as exhaust fans.
    Visit here
    Kitchen Chimney Repair Service in Noida
    Kitchen Kitchen Chimney Repair Service in Vaishali
    Kitchen Kitchen Chimney Repair Service in indirapuram
    Kitchen Kitchen Chimney Repair Service in vasundhra
    Kitchen Kitchen Chimney Repair Service in faridabad

    ReplyDelete
  26. Cheap airline tickets deal


    Are you searching the best Airline Tickets & Last Minute Airline Flights in Nigeria? Get the best Best Airline Tickets & Last Minute Airline Flights at AirlineDeals with the low-cost price.

    to get more - https://airlinedeals.net/flights/

    ReplyDelete
  27. Discount hotels deal online

    Discount Hotels Deal Online - With airline deals you able to get cheap airline tickets deal, Package, last-minute airline flights, discount hotels deal online in last minutes with best affordable prices.
    to get more - https://airlinedeals.net/last-minute-hotels-deals-package/

    ReplyDelete
  28. Discount hotels deal online

    Discount Hotels Deal Online - With airline deals you able to get cheap airline tickets deal, Package, last-minute airline flights, discount hotels deal online in last minutes with best affordable prices.

    to get more - https://airlinedeals.net/last-minute-hotels-deals-package/

    ReplyDelete
  29. If you are looking for Self learning, Distance Education Courses are becoming increasingly popular as a mode of education and are being utilized by professionals and students from around the world, there are numerous possibilities for distance learning courses. Just go through this link:-

    Distance Education Courses ,

    ReplyDelete
  30. Are you looking for Distance Learning Courses in India most of the students choose and apply, Talentedgenex there are many popular courses which attract the students for having distance education. For more info visit this site:- Distance learning courses in India ,

    ReplyDelete
  31. Talentedgenext Way of Online Learning, Distance Education, is an increasing number of becoming popular all over the world due as it has many benefits. For further details visit in this site:- Distance Education Website,

    ReplyDelete
  32. Online BBA degree in India is one of the most popular couses for students who are keen to learn business statistics, communicating skills, marketing management, entrepreneurship and small business management, international business, etc. To know more, visit:
    Online BBA Degree in India,

    ReplyDelete
  33. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Selenium Training in Electronic City

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...