Categories
Uncategorized

Package in Java

package tr2; public class pack { private int callme; public String name; private void pdis() { callme=5; System.out.println(“This is private method calling callme ” + callme); } public void pudis() { System.out.println(“This is public method”); }        public static void main(String args[]) { pack p2=new pack(); p2.pdis(); } } package package1; import tr2.pack; public […]

Categories
Uncategorized

Single Inheritance

Simple example of single inheritance import java.util.Scanner; class rectangle { double length, breadth; void get() { Scanner a= new Scanner(System.in); System.out.println(“enter lenght and breadth:”); length=a.nextDouble(); breadth=a.nextDouble(); } void display() { double ar; ar=length*breadth; System.out.println(“Area of Rectangle:”+ar); } } class square extends rectangle