What Will Be The Output Of The Following Java Codep Pre #852
What will be the output of the following Java code?</p> <pre><code class="language-java"> import java.util.*; class A { LinkedList l = new LinkedList(); } class B extends A { void add(int a) { l.add(a); } } class C extends B { public void remove(int a) { l.remove(a); } } public class list { public static void main(String[] args) { C c = new C(); c.add(1); c.add(2); c.add(3); c.add(4); c.remove(3); System.out.println(c.l); } }</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs111 OOP Object Oriented Programming Java. It can also be found in gs gs111 Inheritance (Using Java) - Multilevel Inheritance - Quiz No.2.