What will be the output of the following Java code?class A {public int i;public int j;A() {i = 1;j = 2;}} class B extends A {int a;B() {super();} } class super_use {public static void main(String args[]){B obj = new B();System.out.println(obj.i + " " + obj.j) } }

🎲 Try a Random Question  |  Total Questions in Quiz: 41  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
Java Basics Practice Test: Inheritance — practice the complete quiz, review flashcards, or try a random question.

Java Quiz on the concepts of objects, method overriding, inheritance, abstract class and super. Inheritance in Java is an important concept in object-oriented programming. It allows you to create new classes that are built upon existing classes. This can be useful for code reuse, as you can inherit the properties and methods of an existing class without having to rewrite them. There are five types of inheritance in Java: Single inheritance: This is the simplest type of inheritance, where a class inherits from a single parent class. Multilevel inheritance: This type of inheritance occurs... Show more

What will be the output of the following Java code?<br>class A <br>{<br>public int i;<br>public int j;<br>A() <br> {<br>i = 1;<br>j = 2;<br>}<br>} <br>class B extends A <br>{<br>int a;<br>B() <br>{<br>super();<br>} <br>} <br>class super_use <br>{<br>public static void main(String args[])<br>{<br>B obj = new B();<br>System.out.println(obj.i + " " + obj.j) <br>}<br> }