<?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>java packages Archives -</title>
	<atom:link href="https://mitindia.in/tag/java-packages/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/java-packages/</link>
	<description></description>
	<lastBuildDate>Sat, 09 Jul 2016 07:50:31 +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>java packages Archives -</title>
	<link>https://mitindia.in/tag/java-packages/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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>
