Skip to content

Category Archives: Java Quiz

Output of following Java program class Main {  public static void main(String args[]){    final int i;    i = 20;    System.out.println(i);  } } (A) 20 (B)… Read More
Predict the output? class Main {     public static void main(String args[]) {                 System.out.println(fun());     }        static int fun(int x = 0)     {       return x;     } }… Read More
In Java, can we make functions inline like C++? (A) Yes (B) No Answer: (B) Explanation: Unlike C++, in Java we can’t suggest functions as… Read More
class intWrap {    int x; }  public class Main {      public static void main(String[] args) {        intWrap i = new intWrap();        i.x = 10;        intWrap… Read More
class Test { public static void swap(Integer i, Integer j) {       Integer temp = new Integer(i);       i = j;       j = temp;    }    public static… Read More
public class Main {      public static void main(String args[]) {         String x = null;         giveMeAString(x);         System.out.println(x);      }      static void giveMeAString(String y)      {         y = "GeeksQuiz"; … Read More
Predict the output of following Java program. class Test {      public static void main(String[] args) {        for(int i = 0; 0; i++)        {            System.out.println("Hello");            break; … Read More
Output of following Java program? class Main {     public static void main(String args[]) {                 System.out.println(fun());     }          int fun()     {       return 20;     } } (A)… Read More
class Main {       public static void main(String args[]) {                int t;                System.out.println(t);      }    } (A) 0 (B)… Read More
Predict the output of following Java program class Test {   int i; }  class Main {   public static void main(String args[]) {        Test t =… Read More
Predict the output of following Java program? class Test {   int i; }  class Main {    public static void main(String args[]) {       Test t;       System.out.println(t.i); … Read More
final class Complex {        private final double re;     private final double im;        public Complex(double re, double im) {         this.re = re;         this.im =… Read More
Predict the output of following Java Program // filename Main.java class Grandparent {     public void Print() {         System.out.println("Grandparent's Print()");     } }     class Parent extends… Read More
Which of the following is true about inheritance in Java. 1) In Java all classes inherit from the Object class directly or indirectly. The Object… Read More
Which of the following is true about interfaces in java. 1) An interface can contain following type of members. ....public, static, final fields (i.e., constants)… Read More

Start Your Coding Journey Now!