The Artima Developer Community
Sponsored Link

Java Buzz Forum
Inheritance Definition and Programs

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Inheritance Definition and Programs Posted: Mar 6, 2015 1:28 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Inheritance Definition and Programs
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • Getting the properties from one class object to other class is known as inheritance.
  • In this inheritance will have parent class and child class so getting the properties of parent class object to child class object known as inheritance.
  • In this we have two types.
  • Multilevel inheritance
  • Multiple inheritance

Multilevel inheritance:

  • Getting the properties from super class object to sub class object level wise with different priorities known as multiple inheritance.

Super class:

  1. package instanceofjava; 

  2. public class Super {
  3.  
  4.     int a,b;
  5.  
  6. void add(){
  7.  
  8.     System.out.println((a+b));
  9.  
  10. }
  11.  
  12. }

Sub class:

  1. package instanceofjava;
  2.  
  3. public class Sub extends Super {
  4.  
  5. void show(){
  6.  
  7.       System.out.println("this is sub class show() method");
  8.  
  9. }
  10.  
  11. public static void main(String [] args){
  12.  
  13.        Sub obj= new Sub();
  14.  
  15.         obj.a=1;
  16.         obj.b=2;
  17.  
  18.         obj.add();
  19.         obj.show();
  20.  
  21.     }
  22. }

Output:

  1. 3
  2. this is sub class show() method

Read: Inheritance Definition and Programs

Topic: LOVs in Oracle MAF Previous Topic   Next Topic Topic: Day 9 of 30 Min Project 12/23/14

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use