Logo

Java Questions Set 59:

Quiz Mode

Which of these classes is not part of Java's Collection framework?

1
2
3
4

Solution:

Which of the following method checks for equality of 2 strings?

1
2
3
4

Solution:

Which method is used to determine the type of content in a URL?

1
2
3
4

Solution:

Which of the following methods of the“ StringBuffer” class is used to find the length of a String?

1
2
3
4

Solution:

 

<p>2</p>
<p>3</p>
<p>4</p>

<p>1</p>

<p>5</p>
function demo()
{
  var element = document.getElementsByTagName("P").length;
  alert(element);
}

1
2
3
4

Solution:

What will be the output of the following Java program?

import java.net.*;

class Networking

{

public static void main(String[] args) throws MalformedURLException

{

URL obj = new URL("https://www.sanfoundry.com/javamcq");

System.out.print(obj.getPort());

}

}

1
2
3
4

Solution:

Which of the following are advantages of packages?

1
2
3
4

Solution:

What will be the output of the program?

class Equals
{
   public static void main(String [] args)
   {
       int x = 100;
       double y = 100.1;
       boolean b = (x = y); /* Line 7 */
       System.out.println(b);
   }
}

1
2
3
4

Solution:

Predict the output of the following Java code.

import java.util.*;

class Abekus {

public static void main(String args[]) {

Formatter F = new Formatter();

F.format("%,d", 345000);

System.out.println(F);

F.format("%,d", -230000);

System.out.println(F);

}

}

1
2
3
4

Solution:

Predict the output of the following Java code:

import java.util.*;

public class Abekus {

public static void main(String[] args) {

PriorityQueue<Integer> pq = new PriorityQueue<>();

pq.add(36);

pq.add(11);

pq.add(82);

pq.add(50);

pq.add(62);

while (!pq.isEmpty())

System.out.printf("%d ", pq.remove());

}

}

1
2
3
4

Solution: