0% found this document useful (0 votes)
5 views5 pages

Oop XM

The document defines an abstract Shape class with abstract methods for calculating the area of different shapes. The Area class extends Shape and implements the abstract methods to calculate and print the areas of a rectangle, square, and circle by overriding the abstract methods. The main method creates an Area object and calls its methods to calculate the areas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Oop XM

The document defines an abstract Shape class with abstract methods for calculating the area of different shapes. The Area class extends Shape and implements the abstract methods to calculate and print the areas of a rectangle, square, and circle by overriding the abstract methods. The main method creates an Area object and calls its methods to calculate the areas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

public abstract class Shape {

public abstract void RectangleArea(float length, float breadth);


public abstract void SquareArea(float side);
public abstract void CircleArea(float radius);
}
class Area extends Shape {

@Override
public void RectangleArea(float length, float breadth) {
System.out.println(("Rectangle area is :" + length*breadth));
}

@Override
public void SquareArea(float side) {
System.out.println("Square Area is: " + side*side);
}

@Override
public void CircleArea(float radius) {
System.out.println("Circle Area is: "+ radius*radius*3.14);
}
}
class Main {
public static void main(String[] args) {
Area a=new Area();
a.CircleArea(4f);
a.RectangleArea(2f,3f);
a.SquareArea(5f);
}
}
1

package com.Arkhan;
import java.util.*;
class FibonacciSeries
{
static int fib(int n)
{
int []f = new int[n+2];
int i;
f[1] = 0;
f[2] = 1;

for (i = 3; i <= n; i++)


{
f[i] = f[i-1] + f[i-2];
}
return f[n];
}

public static void main (String[] args)


{
System.out.println("Enter the nth number to find: ");
Scanner sc= new Scanner(System.in);
int n = sc.nextInt();
System.out.println("Nth number in Fibonacci series is: " + fib(n));
}
}

package com.Arkhan;
abstract class BangladeshBank{
abstract void getInterestRate();
}
class IFIC extends BangladeshBank{
@Override
void getInterestRate(){
System.out.println("5.6%");
}
}
class EBL extends BangladeshBank{

@Override
void getInterestRate() {
System.out.println("6.2%");

}
}
class Southeast extends BangladeshBank{
@Override
void getInterestRate()
{
System.out.println("5.6%");
}
}

class AbstractClass {
public static void main(String args[]){
IFIC r = new IFIC();
r.getInterestRate();

EBL s = new EBL();


s.getInterestRate();

Southeast a = new Southeast();


a.getInterestRate();

}
}

4
package com.Arkhan;
public class ThrowExample {
void Validate(int numb) {

if (numb < 0) {
throw new ArithmeticException("Invalid input.");
} else {
System.out.println("division is possible.");
}
}

public static void main(String[] args) {


ThrowExample it = new ThrowExample();
it.Validate(0);
}
}

You might also like