Java 233
Java 233
Java 233
Practical 1
1.A.(a) Program to demonstrate use of constructor overloading.
Code:
class St
public St ()
System.out.println(a+b);
class Pr48
St s1=new St();
St s2 = new St(27,11);
}
Roll no--233
Output:
Code--
package copyex;
import java.util.Scanner;
Circle()
r=sc.nextFloat();
Circle(Circle x)
r=x.r;
Roll no--233
void calculate()
area=3.14f*r*r;
void display()
System.out.println("area="+area);
package copyex;
c.calculate();
c.display();
c1.calculate();
c1.display();
}
}
Roll no--233
OUTPUT-
Code:
package javaapplication13;
class JavaApplication13 {
System.out.println(num1+num2);
System.out.println(num1+num2);
System.out.println(num1);
}
Roll no--233
s1.add(27,56);
s1.add(5.f,6.5f);
s1.add(88);
Output:
Roll no--233
1(c) Aim— Write program to create a class and implements the concept
of static method .
Code--
package staticmethod;
class Employee {
int empid;
String name;
company = "sall";
empid= e;
name= n;
void display(){
Employee.change();
e1.display();
e2.display();
OUTPUT--
Roll no--233
Practical 2
Code--
class A
void show() {
System.out.println("Base class");
class B extends A
@Override
void show()
System.out.println("Derieved Class");
class Main
B s=new B();
Roll no--233
s.show();
Output--
Code--
package abstractclass;
import java.util.*;
r=x;
vol=3.14f*r*r*r*4/3;
float x;
x = sc.nextFloat();
s.read(x);
s.calculate();
System.out.println("Sphere:");
s.display();
Roll no--233
Output--
Code--
package interfaces;
interface area{
System.out.println("Area of rectangle:");
System.out.println(s*t);
}
Roll no--233
System.out.println("Area of circle:");
System.out.println(3.14f*s*s);
r.show(3,4);
c.show(3,4);
Output--