<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>multilevel inheritance Archives -</title>
	<atom:link href="https://mitindia.in/tag/multilevel-inheritance/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/multilevel-inheritance/</link>
	<description></description>
	<lastBuildDate>Sun, 13 Dec 2020 07:44:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>multilevel inheritance Archives -</title>
	<link>https://mitindia.in/tag/multilevel-inheritance/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Multilevel, Hierarchical and Hybrid Inheritance</title>
		<link>https://mitindia.in/multilevel-hierarchical-and-hybrid-inheritance/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Sun, 13 Dec 2020 07:26:15 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[hierarchical inheritance in python]]></category>
		<category><![CDATA[hybrid inheritance in python]]></category>
		<category><![CDATA[multilevel inheritance]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=1071</guid>

					<description><![CDATA[<p>Multilevel, Hierarchical and Hybrid Inheritance Multi-Level Inheritance in Python #Multilevel Inheritance in Python class India: def first(self): print ('India is the largest democratic country in the world') class Karnataka(India): def sec(self): print ('Karnataka is famous for IT and Coffee Production') class Bengaluru(Karnataka): def third(self): print ('Bengaluru also known as Garden city!') b=Bengaluru() b.first() b.sec() b.third() [&#8230;]</p>
<p>The post <a href="https://mitindia.in/multilevel-hierarchical-and-hybrid-inheritance/">Multilevel, Hierarchical and Hybrid Inheritance</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Multilevel, Hierarchical and Hybrid Inheritance</p>
<ol>
<li>Multi-Level Inheritance in Python</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="null">#Multilevel Inheritance in Python
class India:
    def first(self):
        print ('India is the largest democratic country in the world')

class Karnataka(India):
    def sec(self):
        print ('Karnataka is famous for IT and Coffee Production')

class Bengaluru(Karnataka):
    def third(self):
        print ('Bengaluru also known as Garden city!')
b=Bengaluru()
b.first()
b.sec()
b.third()
</pre>
<p>Output of the above program is :</p>
<blockquote><p>India is the largest democratic country in the world<br />
Karnataka is famous for IT and Coffee Production<br />
Bengaluru also known as Garden city!</p></blockquote>
<p>2. Hierarchical Inheritance in Python example</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null"># Hierarchial Inheritance using Python
class Details:
    def __init__(self):
        self.__id=""       
        self.__name=""
        self.__gender=""
    def setData(self,id,name,gender):
        self.__id=id
        self.__name=name
        self.__gender=gender
    def showData(self):
        print("Id: ",self.__id)
        print("Name: ", self.__name)
        print("Gender: ", self.__gender)
class Employee(Details): #Inheritance
    def __init__(self):
        self.__company=""
        self.__dept=""
    def setEmployee(self,id,name,gender,comp,dept):
        self.setData(id,name,gender)
        self.__company=comp
        self.__dept=dept
    def showEmployee(self):
        self.showData()
        print("Company: ", self.__company)
        print("Department: ", self.__dept)
class Doctor(Details): #Inheritance
    def __init__(self):
        self.__hospital=""
        self.__dept=""
    def setDoctor(self,id,name,gender,hos,dept):
        self.setData(id,name,gender)
        self.__hospital=hos
        self.__dept=dept
    def showDoctor(self):
        self.showData()
        print("Hospital: ", self.__hospital)
        print("Department: ", self.__dept)

def main2():
    print("Employee Object")
    e=Employee()
    e.setEmployee(1,"SHARAN","Male","ITC","Sales Manager")
    e.showEmployee()
    print("\nDoctor Object")
    d = Doctor()
    d.setDoctor(1, "Ramesh", "Male", "AIIMS", "ENT")
    d.showDoctor()
main2()
</pre>
<p>Output of the above program is :</p>
<blockquote><p>Employee Object<br />
Id: 1<br />
Name: SHARAN<br />
Gender: Male<br />
Company: ITC<br />
Department: Sales Manager</p>
<p>Doctor Object<br />
Id: 1<br />
Name: Ramesh<br />
Gender: Male<br />
Hospital: AIIMS<br />
Department: ENT</p></blockquote>
<p>3. Hybrid Inheritance in Python</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">#Hybrid Inheritance using Python
class Emp:
    cname="MIT India"
 
class SystemAdmin(Emp):
    srole="System Admin"
     
class WebDev(Emp):
    wrole="UI Developer"
     
class DBA(WebDev, SystemAdmin,Emp):
    drole="Data Base Creating"
     
obj=DBA()
print("Company Name:"+obj.cname)
print("SysAdmin:"+obj.srole)
print("WebDev:"+obj.wrole)
print("DBA:"+obj.drole)
</pre>
<p>Output of the above program is :</p>
<blockquote><p>Company Name:MIT India<br />
SysAdmin:System Admin<br />
WebDev:UI Developer<br />
DBA:Data Base Creating</p></blockquote>
<p>&nbsp;</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fmultilevel-hierarchical-and-hybrid-inheritance%2F&amp;linkname=Multilevel%2C%20Hierarchical%20and%20Hybrid%20Inheritance" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fmultilevel-hierarchical-and-hybrid-inheritance%2F&amp;linkname=Multilevel%2C%20Hierarchical%20and%20Hybrid%20Inheritance" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fmultilevel-hierarchical-and-hybrid-inheritance%2F&#038;title=Multilevel%2C%20Hierarchical%20and%20Hybrid%20Inheritance" data-a2a-url="https://mitindia.in/multilevel-hierarchical-and-hybrid-inheritance/" data-a2a-title="Multilevel, Hierarchical and Hybrid Inheritance"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/multilevel-hierarchical-and-hybrid-inheritance/">Multilevel, Hierarchical and Hybrid Inheritance</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Java Inheritance and packages</title>
		<link>https://mitindia.in/java-inheritance-and-packages/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Thu, 30 Jun 2016 08:39:51 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java packages]]></category>
		<category><![CDATA[multilevel inheritance]]></category>
		<category><![CDATA[multiple inheritance]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=207</guid>

					<description><![CDATA[<p>Java Program to display Student Marks information using Single Inheritance. import java.io.*; class Student { int rollno; String nm; } class Marks extends Student { int p, c, m, tot; Marks() { try { DataInputStream in=new DataInputStream(System.in); System.out.print("Enter Roll No:"); rollno=Integer.parseInt(in.readLine()); System.out.print("Enter Name:"); nm=in.readLine(); System.out.print("Enter Phy Marks:"); p=Integer.parseInt(in.readLine()); System.out.print("Enter Che Marks:"); c=Integer.parseInt(in.readLine()); System.out.print("Enter Maths Marks:"); [&#8230;]</p>
<p>The post <a href="https://mitindia.in/java-inheritance-and-packages/">Java Inheritance and packages</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Java Program to display Student Marks information using Single Inheritance.</p>
<pre>import java.io.*;
class Student 
{
int rollno;
String nm;
}
class Marks extends Student
{
int p, c, m, tot;
Marks()
{
try
{
DataInputStream in=new DataInputStream(System.in);
System.out.print("Enter Roll No:");
rollno=Integer.parseInt(in.readLine());

System.out.print("Enter Name:");
nm=in.readLine();

System.out.print("Enter Phy Marks:");
p=Integer.parseInt(in.readLine());

System.out.print("Enter Che Marks:");
c=Integer.parseInt(in.readLine());

System.out.print("Enter Maths Marks:");
m=Integer.parseInt(in.readLine());
tot=p+c+m;
}
catch(IOException e) {System.out.println("Error in input"); System.exit(1);}
}
void show()
{
System.out.println("RollNo : " + rollno);
System.out.println("Name : " + nm);
System.out.println("Physics : " + p);
System.out.println("Chemistry : " + c);
System.out.println("Maths : " + m);
System.out.println("Total : " + tot);
}
}
class Inherit
{
public static void main(String args[])
{
Marks sm=new Marks();
sm.show();
}
}</pre>
<p>Java program to display Employee Salary information using Inheritance.</p>
<pre>class Emp_det
{
int eno=100;
String nm="Ravi";
}

class Salary extends  Emp_det
{
int bs=34567, pf=500;
int net=bs-pf;

void show()
{
System.out.println("Employee Number:" +eno);
System.out.println("Employee Name:" +nm);
System.out.println("Employee Basic Pay:" +bs);
System.out.println("Employee PF:" +pf);
System.out.println("Employee Net Pay:" +net);
}
}
public class Inherit_emp
{
public static void main(String args[])
{
Salary s=new Salary();
s.show();
}
}</pre>
<p>Java Program to show Multiple Inheritance using Java Interface</p>
<pre>import java.lang.*;
import java.io.*;

interface Exam
{
void percent_cal();
}
class Student
{
String name;
int roll_no,mark1,mark2;
Student(String n, int r, int m1, int m2)
{
name=n;
roll_no=r;
mark1=m1;
mark2=m2;
}

void display()
{
System.out.println ("Name of Student: "+name);
System.out.println ("Roll No. of Student: "+roll_no);
System.out.println ("Marks of Subject 1: "+mark1);
System.out.println ("Marks of Subject 2: "+mark2);
}
}
class Result extends Student implements Exam
{
Result(String n, int r, int m1, int m2)
{
super(n,r,m1,m2);
}

public void percent_cal()
{
int total=(mark1+mark2);
float percent=total/2;
System.out.println ("Percentage: "+percent+"%");
}
    
void display()
{
super.display();
}
}
class Mi
{
public static void main(String args[])
{
Result R = new Result("John",01,90,84);
R.display();
R.percent_cal();
}
}</pre>
<p>Java Program to show Multi Level Inheritance.</p>
<pre>class A 
{ 
void DisplayA() 
{ 
System.out.println("Class A"); 
} 
} 

class B extends A 
{ 
void DisplayB() 
{ 
System.out.println("Class B"); 
} 
} 

class C extends B 
{ 
void DisplayC() 
{ 
System.out.println("Class C"); 
} 
} 

class MLevel 
{ 
public static void main(String args[]) 
{ 
C c = new C(); 
c.DisplayA(); 
c.DisplayB(); 
c.DisplayC(); 
} 
}</pre>
<h3>Java Packages</h3>
<p>Java Packages enable grouping of functionally related classes<br />
Package names are dot separated, e.g., java.lang.<br />
Package names have a correspondence with the directory structure.<br />
Packages Avoid name space collision.<br />
There can not be two classes with same name in  a same Package But two packages can have a class with same name.</p>
<div></div>
<p><b>To Create user defined Packages in Java, follow the steps. </b><br />
1. Create a folder named eg: <b>mypack </b>in your current working directory.<br />
2. Create a file called &#8220;<b>Welcome.java</b>&#8221; in <b>mypack</b> folder only with following code in it.</p>
<pre>package mypack;
public class Welcome
{
public void show()
{
System.out.println("Welcome to user defined packages!");
}
}</pre>
<p>3. Compile the above program and let it create the .class file (something like Welcome.class) but don&#8217;t run this program! I repeat only compile it.</p>
<p>4. Now, please come out from the directory or folder or package folder &#8220;<b>mypack</b>&#8221; and stay in your normal java or javaprograms directory, now create an another java file, namely, eg:<b>pack.java</b></p>
<p>5. Enter the following code into &#8220;<b>pack.java</b>&#8221;</p>
<pre>import mypack.Welcome;
class pack
{
public static void main(String args[])
{
Welcome w=new Welcome();
w.show();
}
}</pre>
<p>6. Now, compile and run the above program, you can see the following line of output message which was actually written  in the package called &#8220;<b>Welcome.java</b>&#8220;.</p>
<pre>Welcome to user defined packages!</pre>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fjava-inheritance-and-packages%2F&amp;linkname=Java%20Inheritance%20and%20packages" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fjava-inheritance-and-packages%2F&amp;linkname=Java%20Inheritance%20and%20packages" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fmitindia.in%2Fjava-inheritance-and-packages%2F&#038;title=Java%20Inheritance%20and%20packages" data-a2a-url="https://mitindia.in/java-inheritance-and-packages/" data-a2a-title="Java Inheritance and packages"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/java-inheritance-and-packages/">Java Inheritance and packages</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
