Our social:

Top 10 MCQS For JAVA Programmer | HackHackers

Hey , I am Here WIth very exciting 10 MCQS which will test your knowledge In java programming .. Let's check whether you are able to answer it or not.



1 ) Which of these best describes the below code?

class M : public N, public P 
{}


Answer : 
It is true ?? Think And answer below MCQS In comment Box

2) Predict the output of below Java code:

class TestClass {
    public static void main(String args[] ) throws Exception {
        String d = "java ";
        d += d;
        d += "world of ";
        d.concat("programming ");
        System.out.println(d);
    }
}




Answer : 


3 ) Predict the output of below Java code:

import java.util.*;
    class Output {
        public static void main(String args[]) {
            ArrayList al = new ArrayList();
            al.add("A");
            al.add(10);
            al.add(null);
            System.out.println(al);
        }
    }




Answer :


4 ) Predict the output of below Java code:

class Sample {
    public static void main(String args[])
    {
        int x , y = 1;
        x = 10;
        if (x != 10 && x / 0 == 0)
            System.out.println(y);
        else
            System.out.println(++y);
    }
}
5 ) Predict the output of below Java code:

class Demo{
    public static void main(String args[])
    {
        String chars[] = {"a", "b", "c", "a", "c"};
        for (int i = 0; i < chars.length; ++i)
            for (int j = i + 1; j < chars.length; ++j)
                if(chars[i].compareTo(chars[j]) == 0)
            System.out.print(chars[j]);
        }
    }
Answer :  
6 ) Predict the output of below Java code:

class Demo{
    public static void main(String args[])
    {
        String s = "Hello World";
        int i = s.indexOf('o');
        int j = s.lastIndexOf('l');
        System.out.print(i + " " + j);

    }
}
Answer :
7 ) Predict the output of below Java code:

public class Test
{
    int x =2;
    Test(int i) { x = i; }
    public static void main(String[] args) {
        Test t = new Test(3);
        System.out.println("x = " + t.x);
    }
}
Answer : 
8 ) Predict the output of below Java code:

class Equality {
    int x;
    int y;
    boolean isequal() {
        return(x == y);
    }
}
class Output {
    public static void main(String args[])
    {
        Equality obj = new Equality();
        obj.x = 10;
        obj.y = 10;
    System.out.println(obj.isequal());        }
}
Answer : 
9 ) Predict the output of below Java code:

class newthread implements Runnable {
    Thread t;
    newthread() {
        t = new Thread(this,"Hello");
        t.start();
    }
    public void run() {
        System.out.println(t.getName());
    }
}
class multithreaded_programing {
    public static void main(String args[]) {
        new newthread();
    }
}
Answer : 
10 ) Predict the output of below Java code:

public class test {
    public static void main(String args[]) {
        int x,y;
        x = 3 & 6;
        y = 3 | 6;
        System.out.println(x + " " + y);
    }
}
Answer :

Any Doubts ? Need Answer ? Comment Below ..!!! :-) 
                 
          ANSWER