Sravya Oopj Writeups
Sravya Oopj Writeups
Batch : B3
Enrollment No. : A70405221162
PROGRAM:
package com.company;
import java.util.Scanner;
public class exp1 {
public static void main(String args[]) {
args = new String[3];
Scanner sc = new Scanner(System.in);
for(int i=0;i<args.length;i++){
Program:
class Shape {
public void area(){ System.out.println("Area of Shape");
}
}
}
}
//multilevel inheritance
//hierarchical inheritance
class Circle extends Shape{
public void area(int r){
System.out.println("area of circle is : " +
(3.14)*r*r);
}
}
//object define
}
output :
Name : SRAVYA PARIDALA
Enrollment No. :A70405221162
Aim : Constructor
Program :
package com.company;
class phone {
phone() {
System.out.println("phone is electronic device");
}
public void smartphone() {
System.out.println("we can play game on smartphone");
}
}
public class experiment6 {
public static void main(String[] args) {
phone Ph = new phone();
Ph.smartphone();
}
}
Output :
Name : SRAVYA PARIDALA
Enrollment No. :A70405221162
Program :
package com.company;
class maths{
int sum(int a, int b){
return a+b;
}
double sum(int x, double y){
return x +y;
}
double sum (double x, double y){
return x + y;
}
}
public class experiment4 {
public static void main(String[] args) {
int a;
double b,c;
maths M1 = new maths();
a = M1.sum(2,3);
b = M1.sum(3,5.8);
c = M1.sum(5.7,3.4);
System.out.println("The sum is "+ a);
System.out.println("The sum is "+ b);
System.out.println("The sum is "+ c);
}
}
output :
Name : SRAVYA PARIDALA
Enrollment No. :A70405221162
Program :
class A {
public void maths(int a, int b){
System.out.println("sum of two numbers is " + (a +
b));
}
public void methode(){
System.out.println("this is method");
}
}
class B extends A{
public void maths(int a, int b){
System.out.println("multiplication of two numbers is "
+ (a*b));
}
public void methode(){
System.out.println("this is override methode");
}
}
public class experiment_5 {
public static void main(String[] args) {
A a = new A();
a.maths(4,6);
a.methode();
B b = new B();
b.maths(5,6);
b.methode();
}
}
Output:
Name : SRAVYA PARIDALA
Enrollment No. :A70405221162
Program :
class numbers{
int a,b;
public int multiplication(){
return a*b;
}
numbers(int x, int y){
this.a=x;
this.b=y;
}
}
class divide extends numbers{
divide (int c,int d){
super(c,d);
System.out.println("division of two numbers is "+
(c/d));
}
}
public class experiment_7 {
public static void main(String[] args) {
divide D = new divide(9,3);
System.out.println("multiplication of two numbers is "
+ D.multiplication());
}
}
Output :
Name : Sravya Paridala
Enrollment no. : A70405221162
Batch : B3
Aim :
Class A - Write a program to find that digit is divisible
by 5
Class B - Write a program to find whether the given
integer is odd or even
Program:
class A{
int x;
public void div(){
this.x=17;
//check number is devide by 5 or not
if (this.x %5 ==0){
else {
class B extends A{
public void oddeven(){
this.x=49;
//check number is even or odd
if(this.x%2==0){
System.out.println("The Number is even");
}
else {
System.out.println("The Number is odd");
}
}
}
}
}
Output:
Cls1.div(); B Cls2 = new B(); Cls2.oddeven(); } }
Outpute: