Programming in JAVA.
Java Week 4: Q3
The program in this assignment is attempted to print the following output:
-----------------OUTPUT-------------------
This is large
This is medium
This is small
This is extra-large
-------------------------------------------------
However, the code is intentionally injected with some bugs. Debug the code to execute the program successfully.
PROGRAM:
interface ExtraLarge{
String extra = "This is extra-large";
void display();
}
class Large {
public void Print() {
System.out.println("This is large");
}
}
class Medium extends Large {
public void Print() {
super.Print();
System.out.println("This is medium");
}
}
class Small extends Medium {
public void Print() {
super.Print(); ;
System.out.println("This is small");
}
}
class Question43 implements ExtraLarge{
public static void main(String[] args) {
Small s = new Small();
s.Print();
Question43 q = new Question43();
q.display();
}
public void display(){
System.out.print(extra);
}
}
Java Week 4: Q4
Complete the code segment to call the default method in the interface First and Second.
PROGRAM:
First.super.show();
Second.super.show();
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.