Programming in JAVA.
Java Week 4: Q5
Modify the code segment to print the following output.
-----------------OUTPUT-------------------
Circle: This is Shape1
Circle: This is Shape2
-------------------------------------------------
PROGRAM:
interface ShapeX {
public String base = "This is Shape1";
public void display1();
}
interface ShapeY extends ShapeX {
public String base = "This is Shape2";
public void display2();
}
class ShapeG implements ShapeY {
public String base = "This is Shape3";
public void display1() {
System.out.println("Circle: " + ShapeX.base);
}
public void display2(){
System.out.println("Circle: " + ShapeY.base);
}
}
Disclaimer: Here you can find all nptel assignment solutions related to CS stream.These may help you for your assignment.The answers are only for verification.You cannot copy these directly from the post(code of conduct of NPTEL).These is not 100% correct solutions.
No comments:
Post a Comment
If you have any problems related to solutions or any concept please let me know.