What is the output of this program?
1.class jump_statments {
2.public static void main(String args[])
3.{
4.int x = 2;
5.int y = 0;
6.for ( ; y < 10; ++y) {
7.if (y % x == 0)
8.continue;
9.else if (y == 8)
10.break;
11.else
12.System.out.print(y + " ");
13.}
14.}
15.}
What is the output of this program?
1.class overload {
2.int x;
3.int y;
4.void add(int a) {
5.x = a + 1;
6.}
7.void add(int a, int b){
8.x = a + 2;
9.}
10.}
11.class Overload_methods {
12.public static void main(String args[])
13.{
14.overload obj = new overload();
15.int a = 0;
16.obj.add(6);
17.System.out.println(obj.x);
18.}
19.}
Which of these classes is used for input and output operation when working with bytes?
What is the output of this program?
1.class string_class {
2.public static void main(String args[])
3.{
4.String obj = "hello";
5.String obj1 = "world";
6.String obj2 = "hello";
7.System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
8.}
9.}
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.String s1 = "abcd";
7.int len1 = s1.length();
8.int len2 = s.length();
9.System.out.println(len1 + " " + len2);
10.}
11.}
What is the output of this program?
1.class Output {
2.public static void.main(String args[])
3.{
4.int a = 5;
5.int b = 10;
6.first: {
7.second: {
8.third: {
9.if (a == b >> 1)
10.break second;
11.}
12.System.out.println(a);
13.}
14.System.out.println(b);
15.}
16.}
17.}
Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Which of these is correct way of inheriting class A by class B?
What is the output of this program?
1.import java.net.*;
2.class networking {
3.public static void main(String[] args) throws MalformedURLException {
5.URL obj = new URL("http://www.sanfoundry.com/javamcq"); System.out.print(obj.toExternalForm());
6.}
7.}
Which of these data member of HttpResponse class is used to store the response from a http server?
What is the value of double constant ‘E’ defined in Math class?
Which of these methods is used to obtain value of invoking object as a long?
Which of these class object uses key to store value?
Which of these method is used to insert value and its key?
Which of these keywords is used to prevent content of a variable from being modified?
Which of these method of ArrayList class is used to obtain present size of an object?
Which of these method of HashSet class is used to add elements to its object?
Which of these interface is not a member of java.io package?
Which of these method of DatagramPacket is used to find the port number?
Which of these method is called when http daemon is acting like a normal web server?
Which of these can not be used for a variable name in Java?
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
What is the output of this program?
1.class A {
2.int i;
3.int j;
4.A() {
5.i = 1;
6. j = 2;
7.}
8.}
9.class Output {
10.public static void main(String args[])
11.{
12.A obj1 = new A();
13.System.out.print(obj1.toString());
14.}
15.}
Which of these keywords is used by a class to use an interface defined previously?
What is the error in this code? byte b = 50; b = b * 50;
What is the output of this program? 1.class mainclass {
2.public static void main(String args[])
3.{
4.boolean var1 = true;
5.boolean var2 = false;
6.if (var1)
7.System.out.println(var1);
8.else
9.System.out.println(var2);
10.}
11.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String c = "Hello i love java";
5.int start = 2;
6.int end = 9;
7.char s[]=new char[end-start];
8.c.getChars(start,end,s,0);
9.System.out.println(s);
10.}
11.}
Which of these method is called when http daemon is acting like a normal web server?
Which of these class is used to read and write bytes in a file?
Which of these interface abstractes the output of messages from httpd?
What is the output of this program?
1.package pkg;
2.class display {
3.int x;
4.void show() {
5.if (x > 1)
6.System.out.print(x + " ");
7.}
8.}
9.class packages {
10.public static void main(String args[]) {
11.display[] arr=new display[3];
12.for(int i=0;i<3;i++)
13.arr[i]=new display();
14.arr[0].x = 0;
15.arr[1].x = 1;
16.arr[2].x = 2;
17.for (int i = 0; i < 3; ++i)
18.arr[i].show();
19.}
20.}
Which of these class object uses key to store value?
Which of these method of DatagramPacket is used to find the length of byte array?
What is the output of this program?
1.class array_output {
2.public static void main(String args[])
3.{
4.int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}};
5.int sum = 0;
6.for (int i = 0; i < 3; ++i)
7.for (int j = 0; j < 3 ; ++j)
8.sum = sum + array_variable[i][j];
9.System.out.print(sum / 5);
10.}
11.}
What is the output of this program?
1.class selection_statements {
2. public static void main(String args[])
3.{
4.int var1 = 5;
5.int var2 = 6;
6.if ((var2 = 1) == var1)
7.System.out.print(var2);
8.else
9.System.out.print(++var2);
10.}
11.}
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.int len = obj1.getContentLength();
7.System.out.print(len);
8.}
9.}
Which of these method of Object class can generate duplicate copy of the object on which it is called?
Which of these method of class String is used to compare two String objects for their equality?
What is the output of this program?
1.class string_class {
2.public static void main(String args[])
3.{
4.String obj = "I LIKE JAVA";
5.System.out.println(obj.length());
6.}
7.}
What is the return type of Constructors?