Skip to content

Category Archives: Java Quiz

Predict the output? // file name: Main.java public class Main {     public static void main(String args[]) {        int arr[] = {10, 20, 30, 40, 50};… Read More
Which of the following is FALSE about abstract classes in Java (A) If we derive an abstract class and do not implement all the abstract… Read More
Predict the output of following program. Note that foo() is public in base and private in derived. class Base {     public void foo() { System.out.println("Base");… Read More
Predict the output of following Java program class T {   int t = 20;   T() {     t = 40;   } } class Main {    public… Read More
Predict the output? package main; class T {   int t = 20; } class Main {    public static void main(String args[]) {       T t1 =… Read More
Which of the following is FALSE about arrays on Java (A) A java array is always an object (B) Length of array can be changed… Read More
Output of following Java program? class Base {     public void Print() {         System.out.println("Base");     }          }    class Derived extends Base {         public void Print() {… Read More
Which of the following is true about inheritance in Java? 1) Private methods are final. 2) Protected members are accessible within a package and inherited… Read More
class Base {     public static void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public static void show() {        System.out.println("Derived::show() called");… Read More
class Base {     final public void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public void show() {        System.out.println("Derived::show() called");     }… Read More
What is the use of final keyword in Java? (A) When a class is made final, a sublcass of it can not be created. (B)… Read More
Output of following Java Program? class Base {     public void show() {        System.out.println("Base::show() called");     } }     class Derived extends Base {     public void show()… Read More