What is the output of this program? 1.class multidimention_array {
2.public static void main(String args[])
3.{
4.int arr[][] = new int[3][];
5.arr[0] = new int[1];
6.arr[1] = new int[2];
7.arr[2] = new int[3];
8.int sum = 0;
9.for (int i = 0; i < 3; ++i)
10.for (int j = 0; j < i + 1; ++j)
11.arr[i][j] = j + 1;
12.for (int i = 0; i < 3; ++i)
13. for (int j = 0; j < i + 1; ++j)
14.sum + = arr[i][j];
15.System.out.print(sum);
16.}
17.}
Which of these interface is not a member of java.io package?
Which of these method of HashSet class is used to add elements to its object?
Which of these tranfer protocol must be used so that URL can be accessed by URLConnection class object?
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. }
Which of the following statements are incorrect?
What is the output of this program?
1.class array_output {
2.public static void main(String args[])
3.{
4.int array_variable [] = new int[10];
5.for (int i = 0; i < 10; ++i) {
6.array_variable[i] = i/2;
7.array_variable[i]++;
8.System.out.print(array_variable[i] + " ");
9. i++;
10.}
11.}
12.}
Which of these methods can be used to search an element in a list?
Which of these is an instance variable of class httpd?
What is the process by which we can control what parts of a program can access the members of a class?
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.obj.width = 10;
11.obj.height = 2;
12.obj.length = 10;
13.int y = obj.width * obj.height * obj.length;
14.System.out.print(y);
15.}
16.}
What is the value returned by unction compareTo() if the invoking string is less than the string compared?
What is the output of this program? 1.class mainclass {
2.public static void main(String args[])
3.{
5.char a = 'A';
5.a++;
6.System.out.print((int)a);
7.}
8.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.ArrayList obj = new ArrayList();
4.obj.add("A");
5.obj.add("D");
6.obj.ensureCapacity(3);
7.obj.trimToSize();
8.System.out.println(obj.size());
9.}
10.}
What is the output of this program?
1.class Abc
2.{
3.public static void .main(String[]args)
4.{
5.String[] elements = { "for", "tea", "too" };
6.String first = (elements.length > 0) ? elements[0]: null;
7.}
8.}
Which of these cannot be declared static?
Which of these is an instance variable of class httpd?
Which of these class is superclass of all other classes?
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int a,b,c,d;
5.a=b=c=d=20
6.a+=b-=c*=d/=20 7.System.out.println(a+" 8."+b+" "+c+" "+d);
9.}
10.}
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int arr[] = {1, 2, 3, 4, 5};
5.for ( int i = 0; i < arr.length - 2; ++i)
6.System.out.println(arr[i] + " ");
7.}
8.}
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int x , y = 1;
5.x = 10;
6.if (x != 10 && x / 0 == 0)
7.System.out.println(y);
8.else
9.System.out.println(++y);
10.}
11.}
What is the output of this program?
1.import java.util.*;
2.class Maps {
3. public static void main(String args[]) {
4.HashMap obj = new HashMap(); 5.obj.put("A", new Integer(1));
6.obj.put("B", new Integer(2));
7.obj.put("C", new Integer(3)); 8.System.out.println(obj.keySet());
9.}
10.}
Which of these is a bundle of information passed between machines?
Which of these method of InputStream is used to read integer representation of next available byte input?
Which of these method of class String is used to extract more than one character at a time a String object?
What is the output of this program?
1.import java.util.*;
2.class stack {
3.public static void main(String args[]) {
4.Stack obj = new Stack();
5.obj.push(new Integer(3));
6.obj.push(new Integer(2));
7.obj.pop();
8.obj.push(new Integer(5));
9.System.out.println(obj);
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.System.out.print(obj1.getContentType());
7.}
8.}
Note: Host URL is written in html and simple text.
Which of these can not be used for a variable name in Java?
Which of these method is used to change an element in a LinkedList Object?
Which of these method(s) is/are used for writing bytes to an outputstream?
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?
Which of these interface abstractes the output of messages from httpd?
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 output of this program?
1.class box {
2.int width;
3.int height;
4.int length;
5.int volume;
6.void finalize() {
7.volume = width*height*length;
8.System.out.println(volume);
9.}
10.protected void volume() {
11.volume = width*height*length;
12.System.out.println(volume);
13.}
14.}
15.class Output {
16.public static void main(String args[])
17.{
18.box obj = new box();
19.obj.width=5;
20.obj.height=5;
21.obj.length=6;
22.obj.volume();
23.}
24.}
Which of these methods is used to compare a specific region inside a string with another specific region in another string?
Which of these is a process of writing the state of an object to a byte stream?
Which of these classes implements Set interface?
Which of these keywords is used to make a class?