What Will Be The Output Of The Following Java Codep Pre #850
What will be the output of the following Java code?</p> <pre><code class="language-java"> class A { int x = 5; } class B extends A { int fact = 1; void fact() { for(int i = 1; i<=x; i++) { fact*=i; } } } class C extends B { void print() { System.out.println(fact); } } public class Factorial { public static void main(String[] args) { C c = new C(); c.fact(); c.print(); } }</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.