Logo

Java Questions Set 185:

Quiz Mode

Which Java class is used to create a directory?

1
2
3
4

Solution:

What is the purpose of the 'this' keyword in Java?

1
2
3
4

Solution:

class test {

public static void main (String[] args) {

  boolean a=true;

  boolean b=!a;

  boolean c=!b|a;

  boolean d=a||!b;

  System.out.println(c+" "+d);

}

}

1
2
3
4

Solution:

Which of these is the correct way of defining a generic class?

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   final int a=10,b=20;

   for(int i=0;a==b;i++)

   {

       System.out.println("Hello");

   }

   System.out.println("World");

}

}

1
2
3
4

Solution:

public class outputs 

    {

        public static void main(String args[]) 

        {

          String str1= new String("Abe");  

          String str2= new String("kus");  

  System.out.println(str1.concat(str2));

 

        } 

    }

1
2
3
4

Solution:

Predict the output of the following Java code:

import java.util.Scanner;

public class Main

{

    public static void main(String args[])

    {

        String str = "Food court";

        String str1 = "Food";

        System.out.println(str.compareTo(str1));

        System.out.println(str1.compareTo(str));

    }

}

1
2
3
4

Solution:

Predict the output of the following Java code:

class Abekua {

static String s = "";

public

static void main(String[] args)

{

P:

for (int i = 1; i < 8; i++) {

if (i == 4)

continue;

if (i == 5)

break P;

s = s + i;

}

System.out.println(s);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code:

import java.util.Scanner;

public class Main

{

    public static void main(String args[])

    {

        String s1="abekus";  

        String s2="Abekus";  

        String s3="school";

        System.out.println(s1.equalsIgnoreCase(s2));

        System.out.println(s1.equalsIgnoreCase(s3));

    }

}

1
2
3
4

Solution:

Which of the following statements is incorrect about the use of generic and parameterized types in Java?

1
2
3
4

Solution: