Logo

Java Questions Set 217:

Quiz Mode

Are all methods in an interface required to be implemented?

1
2

Solution:

Which of these is a protocol for breaking data into packets and sending them to an address across a network?

1
2
3
4

Solution:

public class operators {

public static void main(String[] args)

{

int a = 20, b = 10, c = 0, d = 20, e = 40, f = 30;

System.out.println((a + b * d - e / f));

}

}

Solution:

Which method of the wrapper class Integer is used to obtain the hash code for the invoking object?

1
2
3
4

Solution:

Which of these methods returns the largest whole number less than or equal to a given variable X?

1
2
3
4

Solution:

Which of the following is the correct error when loading a JAR file with a duplicate class name?

1
2
3
4

Solution:

Which of the following is correct about 'public' method?

1
2
3
4

Solution:

What is the output of the following Java code?

class bitwise_operator

{

public static void main(String args[])

{

int var1 = 42;

int var2 = ~var1;

System.out.print(var1 + " " + var2);

}

}

1
2
3
4

Solution:

Predict the output of the following code:

import java.util.Scanner;

public class Main

{

    public static void main(String args[])

    {

        String s1 = "super world";

        System.out.println(s1.contains("super"));

        System.out.println(s1.contains("TV"));

    }

}

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 UnknownHostException

{

InetAddress obj1 = InetAddress.getByName("sanfoundry.com");

InetAddress obj2 = InetAddress.getByName("sanfoundry.com");

boolean x = obj1.equals(obj2);

System.out.print(x);

}

}

1
2
3
4

Solution: