Embed presentation
Download to read offline

![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();
}
}](https://image.slidesharecdn.com/javacode-230513063618-23eb5fc6/75/java-code-pptx-2-2048.jpg)

![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");
}
}](https://image.slidesharecdn.com/javacode-230513063618-23eb5fc6/75/java-code-pptx-4-2048.jpg)
The document defines two interfaces I1 and I2, with I2 extending I1. Class C11 implements I1 and prints "Hello1", C13 extends C11 and overrides m1 to print "Hello4". Class C12 implements I2, overrides m1 to print "Hello3" and defines m2 to print "Hello2". The main method creates objects of C11 and C12, calling their methods. It also defines a Rectangle class with fields length and width, gets user input and checks if width is valid before calculating and printing the area.

![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();
}
}](https://image.slidesharecdn.com/javacode-230513063618-23eb5fc6/75/java-code-pptx-2-2048.jpg)

![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");
}
}](https://image.slidesharecdn.com/javacode-230513063618-23eb5fc6/75/java-code-pptx-4-2048.jpg)