What is the output of this program?
1.class binary {
2.public static void main(String args[]) {
3.int num = 17;
4.System.out.print(Integer.toBinaryString(num));
5.}
6.}
Which API gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
What is the output of this program? 1.class string_demo {
2.public static void main(String args[])
3.{
4.String obj = "I" + "like" + "Java";
5.System.out.println(obj);
6.}
7.}
Which of these keywords is used to define packages in Java?
What is the output of this program?
1.class access{
2.public int x;
3.private int y;
4.void cal(int a, int b){
5.x = a + 1;
6.y = b;
7.}
8.void print() {
9.system.out.println(" " + y);
10.}
11.}
12.class access_specifier {
13.public static void main(String args[])
14.{
15.access obj = new access();
16.obj.cal(2, 3);
17.System.out.println(obj.x);
18.obj.print();
19.}
20.}
At line number 2 below, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
public interface Status
{
/* insert qualifier here */ int MY_VALUE = 10;
}
What is the output of this program?
1.class A {
2.int i;
3.void display() {
4.System.out.println(i);
5.}
6.}
7.class B extends A {
8.int j;
9.void display() {
10.System.out.println(j);
11.}
12.}
13.class inheritance_demo {
14.public static void main(String 15.args[])
16.{
17.B obj = new B();
18.obj.i=1;
19.obj.j=2;
20obj.display();
21.}
22 }
Which of these methods is used to know host of an URL?
Which of these methods of httpd class is used to read data from the stream?
Which of these method is used to add an element to the start of a LinkedList object?
Which of these coding types is used for data type characters in Java?
What is the output of this program?
1.class San
2.{
3.San()throws IOException
4.{
5.}
6.}
7.class Foundry extends San
8.{
9.Foundry()
10.{
11.}
12.public static void 13.main(String[]args)
14.{
15.}
16.}
Which of these statement is incorrect?
Which of these statement is incorrect?
What is the output of this program?
1.class String_demo {
2.public static void main(String args[])
3.{
4.char chars[] = {'a', 'b', 'c'};
5.String s = new String(chars);
6.System.out.println(s);
7.}
8. }
What is the process of defining more than one method in a class differentiated by method signature?
Which of these cannot be declared static?
What is the output of this program?
1.class array_output {
2.public static void main(String args[])
3.{
4.char array_variable [] = new char[10];
5.for (int i = 0; i < 10; ++i) {
6.array_variable[i] = 'i';
7.System.out.print(array_variable[i] + "");
8.}
9.}
10.}
What is the output of this program?
1.import java.util.*;
2.class Bitset {
3.public static void main(String args[]) {
4.BitSet obj = new BitSet(5);
5.for (int i = 0; i < 5; ++i)
6.obj.set(i);
7.System.out.print(obj.get(3));
8.}
9.}
What is the output of this program? 1.class Output {
2.public static void main(String args[])
3.{
4.boolean a = true;
5.boolean b = false;
6.boolean c = a ^ b;
7.System.out.println(!c);
8.}
9.}
An expression involving byte, int, and literal numbers is promoted to which of these?
What is the output of this program?
1.class box {
2.int width;
3.int height;
4.int length;
5.}
6.class mainclass {
7.public static void main(String args[])
8.{
9.box obj = new box();
10.System.out.println(obj);
11.}
12.}
Decrement operator, −−, decreases value of variable by what number?
What is the output of this program?
1.import java.net.*;
2.class networking {
3.public static void main(String[] args) throws Exception {
4.URL obj = new URL("http://www.sanfoundry.com/javamcq");
5.URLConnection obj1 = obj.openConnection();
6.System.out.print(obj1.getContentType());
7.}
8.}
Which of these access specifiers can be used for a class so that it’s members can be accessed by a different class in the different package?
What is the output of this program?
1.import java.net.*;
2.class networking {
3.public static void main(String[] args) throws Exception {
4.URL obj = new URL("http://www.sanfoundry.com/javamcq");
5.URLConnection obj1 = obj.openConnection(); 6.System.out.print(obj1.getLastModified);
7.}
8.}
Note: Host URL was last modified on july 18 tuesday 2013 .
Which of the following operators can operate on a boolean variable? && == ?:
+=
What is the output of this program?
1.import java.util.*;
2.class hashtable {
3.public static void main(String args[]) {
4.Hashtable obj = new Hashtable();
5.obj.put("A", new Integer(3));
6.obj.put("B", new Integer(2));
7.obj.put("C", new Integer(8));
8.System.out.print(obj.toString());
9.}
10.}
What is the output of this program?
1.import java.util.*;
2.class Array {
3.public static void main(String args[]) {
4.int array[] = new int [5];
5.for (int i = 5; i > 0; i--)
6.array[5 - i] = i;
7.Arrays.sort(array);
8.for (int i = 0; i < 5; ++i)
9.System.out.print(array[i]);;
10.}
11.}
Which of the following method of Process class can terminate a process?
What is the output of this program?
1.import java.util.*;
2.class hashtable {
3.public static void main(String args[]) {
4.Hashtable obj = new Hashtable();
5.obj.put("A", new Integer(3));
6.obj.put("B", new Integer(2));
7.obj.put("C", new Integer(8));
8.System.out.print(obj.toString());
9.}
10.}
Which of these method is used to remove all keys/values pair from the invoking map?
Which of these data type value is returned by equals() method of String class?
What is the output of this program?
1.class conversion {
2.public static void main(String args[])
3.{
4.double a = 295.04;
5.int b = 300;
6.byte c = (byte) a;
7.byte d = (byte) b;
8.System.out.println(c + " " + d);
9.}
10.}
What is the output of this program?
1.import java.io.*;
2.public class filesinputoutput {
3.public static void main(String[] args) {
4.String obj = "abc";
5.byte b[] = obj.getBytes();
6.ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
7.for (int i = 0; i < 2; ++ i) {
8.int c;
9.while ((c = obj1.read()) != -1) {
10.if (i == 0) {
11.System.out.print(Character.toUpperCase((char)c));
12.}
13.}
14.}
15.}
16.}
Which of these access specifier must be used for class so that it can be inherited by another sub class?
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String s1 = "Hello";
5.String s2 = s1.replace('l','w');
6.System.out.println(s2);
7.}
8.}
Which of these class is used to encapsulate IP address and DNS?
Which of these method(s) is/are used for writing bytes to an outputstream?
What is the output of this program?
1.import java.util.*;
2.class date {
3.public static void main(String args[]) {
4.Date obj = new Date();
5.System.out.print(obj);
6.}
7.}