interface I1{
void m1();
}
class C11 implements I1{
public void m1(){
System.out.println("Hello1");
}
}
interface I2 extends I1{
public void m2();
}
class C13 extends C11{
public void m1(){
System.out.println("Hello4"
+ "");
}
}
class C12 implements I2{
public void m2(){
System.out.println("Hello2");
}
@Override
public void m1() {
System.out.println("Hello3");
}
}
class InterfaceEx1{
public static void main(String[] args) {
C11 obj1=new C11();
obj1.m1();
C12 obj2=new C12();
obj2.m1();
obj2.m2();
}
}
import java.util.*;
class Rectangle{
float length;
float width;
public void getValue(){
Scanner input=new Scanner(System.in);
System.out.print("Length : ");
length=input.nextFloat();
System.out.print("Width : ");
width=input.nextFloat();
}
public boolean setValue(){
if(width<=0.0 || width>20.0){
return false;
}
return true;
}
public float area(){
return(length*width);
}
}
public class RectangleEx {
public static void main(String[] args) {
Rectangle r1=new Rectangle();
r1.getValue();
if(r1.setValue()==true)
System.out.println(r1.area());
else
System.out.println("Limits Exceeding");
}
}

java code.pptx

  • 1.
    interface I1{ void m1(); } classC11 implements I1{ public void m1(){ System.out.println("Hello1"); } } interface I2 extends I1{ public void m2(); } class C13 extends C11{ public void m1(){ System.out.println("Hello4" + ""); } }
  • 2.
    class C12 implementsI2{ public void m2(){ System.out.println("Hello2"); } @Override public void m1() { System.out.println("Hello3"); } } class InterfaceEx1{ public static void main(String[] args) { C11 obj1=new C11(); obj1.m1(); C12 obj2=new C12(); obj2.m1(); obj2.m2(); } }
  • 3.
    import java.util.*; class Rectangle{ floatlength; float width; public void getValue(){ Scanner input=new Scanner(System.in); System.out.print("Length : "); length=input.nextFloat(); System.out.print("Width : "); width=input.nextFloat(); } public boolean setValue(){ if(width<=0.0 || width>20.0){ return false; } return true; }
  • 4.
    public float area(){ return(length*width); } } publicclass RectangleEx { public static void main(String[] args) { Rectangle r1=new Rectangle(); r1.getValue(); if(r1.setValue()==true) System.out.println(r1.area()); else System.out.println("Limits Exceeding"); } }