Write a Java program to implement the concept of importing classes from user defined package and creating packages.

  package P1; public class student { int rollno; String name; public float marks; public void getstudent(int rno,String n,float m) { rollno=rno; name=n; marks=m; } public void putstudent() { System.out.println("Roll number="+rollno); System.out.println("Name="+name); System.out.println("Marks="+marks); } }  Create Subdirectory P1 in your current working directory  Save it as student.java in subdirectory P1 and compile it … Read moreWrite a Java program to implement the concept of importing classes from user defined package and creating packages.

Write a Java program to implement the concept of importing classes from user defined package and creating packages

  package Pk1; public class student { int rollno; String name; public float marks; public void getstudent(int rno,String n,float m) { rollno=rno; name=n; marks=m; } public void putstudent() { System.out.println("RollNumber="+rollno); System.out.println("Name="+name); System.out.println("Marks="+marks); } }  Create Subdirectory P1 in your current working directory  Save it as student.java in subdirectory P1 and compile it C:\PCKSMPL>cd … Read moreWrite a Java program to implement the concept of importing classes from user defined package and creating packages

Write a program to demonstrate use of extending interfaces.

  interface Circle { final double PI=3.142; } interface Circle2 extends Circle { public void computearea(int radius); } class area implements Circle2 { public void computearea(int radius) { double carea=PI*radius*radius; System.out.println("PI value="+PI); System.out.println("Area of Circle="+carea); } } class demointerface1 { public static void main(String args[]) { area a=new area(); a.computearea(2); } }     Output: … Read moreWrite a program to demonstrate use of extending interfaces.

Write a program to demonstrate use of implementing interfaces.

  interface area { double PI=3.142; double findarea(double m,double n); } class Triangle implements area { public double findarea(double m,double n) { double aot=0.5*m*n; return(aot); } } class Circle implements area { public double findarea(double m,double n) { double aoc=PI*m*n; return(aoc); } } class demointerface { public static void main(String arg[]) { Triangle t=new Triangle(); … Read moreWrite a program to demonstrate use of implementing interfaces.

Write a Java Program to implement multilevel inheritance by applying various access controls to its data members and methods.

  class Length { int l; void setl(int a) { l=a; } void putl( ) { System.out.println("Length="+l); } } class Breadth extends Length { int b; void setb(int y) { b=y; } void putb( ) { System.out.println("Breadth="+b); } } class Height extends Breadth { int h; void seth(int z) { h=z; } void puth( ) … Read moreWrite a Java Program to implement multilevel inheritance by applying various access controls to its data members and methods.

Write a Java Program to implement inheritance and demonstrate use of method overriding.

  class circle { double r; circle(double m) { r=m; } void area() { double acircle=3.142*r*r; System.out.println("Area of Circle"+acircle); } } class shape extends circle { shape(double l) { super(l); } void area() { double perimeter=2*3.142*r; System.out.println("Perimeter="+perimeter); } } class override { public static void main(String arg[]) { shape s=new shape(3.9); s.area(); } }   … Read moreWrite a Java Program to implement inheritance and demonstrate use of method overriding.

Write a Java Program to implement Wrapper classes and their methods.

  class wrapp { public static void main(String args[]) { int regno=1111; float price=13.8f; double val=18.6423; byte size=2; Integer i1=new Integer(regno); Float f1=new Float(price); Double d1=new Double(val); Byte b1=new Byte(size); System.out.println("Wrapper Class"); System.out.println("Integer object=" +i1); System.out.println("Float object=" +f1); System.out.println("Double object=" +d1); System.out.println("Byte object=" +b1); int i2=i1.intValue(); float f2=f1.floatValue(); double d2=d1.doubleValue(); byte b2=b1.byteValue(); System.out.println("Primitive types"); System.out.println("Integer … Read moreWrite a Java Program to implement Wrapper classes and their methods.

Write a Java Program to implement Vector class and its methods.

  import java.util.Vector; class Vectordemo { public static void main(String args[]) { Vector vob=new Vector(2); String codes; String irates; System.out.println("Inserting 3 institute codes in a vector"); codes="121"; vob.addElement(codes); codes="202"; vob.addElement(codes); codes="404"; vob.addElement(codes); System.out.println("vector elements are:"+vob); System.out.println("vector size is new:"+vob.size()); System.out.println("vector capacity is:"+vob.capacity()); System.out.println("Inserting 1 interest rates in a vector"); irates="8.75"; vob.insertElementAt(irates,2); System.out.println("vector elements are:"+vob); System.out.println("vector … Read moreWrite a Java Program to implement Vector class and its methods.

Java program using String Buffer class and its methods.

  class stdmo1 { public static void main(String args[]) { StringBuffer str1=new StringBuffer("I am Varun "); System.out.println("Given string is "+str1); { System.out.println("Length of given string is "+str1.length()); System.out.println("The capacity of string is "+str1.capacity()); System.out.println("The character at an index 7 is "+str1.charAt(7)); System.out.println("String after inserting a substring is "+str1.append("Ganesh Deva")); System.out.println("After removing Ganesh is "+str1.delete(10,17)); System.out.println("After … Read moreJava program using String Buffer class and its methods.

Write a Java program to practice A)- using String class and its methods.

  class stdemo { static String st1="vivekananda"; static String st2="POLYTECHNIC"; static String pt1,pt2,pt3,pt4,pt5,pt6; public static void main(String arg[]) { int lst1=st1.length(); int lst2=st2.length(); pt1=st1.toUpperCase(); pt2=st2.toLowerCase(); pt3=st2.replace('O','A'); pt4=st1.concat(st2); pt5=st2.substring(6); pt6=st2.replace('A','O'); System.out.println(st1+" Length is :"+lst1); System.out.println(st2+" Length is :"+lst2); System.out.println(st1+" in Uppercase :"+pt1); System.out.println(st2+" in Lowercase :"+pt2); System.out.println("Every O replaced with A in string 2 : "+pt3); … Read moreWrite a Java program to practice A)- using String class and its methods.