NPTEL Programming In Java Week 5 Assignment Answers 2022
Q1. Consider the following program. class Question{ static int b =2; } class Answer extends Question{ static int b =20; } public class Questionl extends Answer{ public static void main(String args[]) { b =100; System.out.println (Answer.b); System.out.println (b+Question.b); } } If the program is executed, then what will be the output from the execution? a. 100 102 b. 20 22 c. 102 100 d. 22 20 Answer : Option A Q2. Consider the following program. class Question { int a=40; int b=20; } public class Childl extends Question { int a=100; int b=200; void add (int a, int b) { System.out.println(a+this.b-super.a); } public static void main(String[] args) { Childl c = new Childl(); c.add(10,30); } } If the program is executed, then what will be the output from the execution? a. 170 b. 130 c. 0 d. 260 Answer : a. 170 Q3. What is the output of the following code? class Explanation{ public void Print () { System.out.println("This is Explanation's Print method"); } } class Answer ...