Which of the following package stores all the standard java classes?
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.obj.clear(2);
8.System.out.print(obj);
9.}
10.}
-
-
-
-
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 methods is used to make raw MIME formatted string?
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.}
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.obj.clear();
9.System.out.print(obj.size());
10.}
11.}
Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?
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.get("B"));
9.}
10.}
Which method can be defined only once in a program?
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 will be output of the following code?
1.public class Boxer1 {
2.Integer i;
3. int x;
4.public Boxer1(int y) {
5.x = i+y;
6.System.out.println(x);
7.}
8.public static void main(String[] args) {
9. new Boxer1 (new Integer(4));
10.}
11.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.double x = 3.1;
4.double y = 4.5;
5.double z = Math.max( x, y );
6.System.out.print(z);
7.}
8.}
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 methods is used to check for infinitely large and small values?
Which of these keywords is used to define packages in Java?
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.}
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 keyword can be used in subclass to call the constructor of superclass?
Which of the following statements are incorrect?
What is the name of data member of class Vector which is used to store number of elements in the vector?
Which of these methods of httpd class is used to read data from the stream?
Which of these are selection statements in Java?
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.
What is the output of this program?
1.import java.util.*;
2.class vector {
3.public static void main(String args[]) {
4.Vector obj = new Vector(4,2); 5.obj.addElement(new Integer(3));
6.obj.addElement(new Integer(2));
7.obj.addElement(new Integer(6));
8.obj.insertElementAt(new Integer(8), 2);
9.System.out.println(obj);
10.}
11.}
-
-
-
-
Which of these are selection statements in Java?
What is the output of this program? 1.class A {
2.int i;
3.}
4.class B extends A {
5.int j;
6.void display() {
7.super.i = j + 1;
8.System.out.println(j + " " + i);
9.}
10.}
11.class inheritance {
12.public static void main(String args[])
13.{
14.B obj = new B();
15.obj.i=1;
16.obj.j=2;
17.obj.display();
18.}
19.}
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;
}
Which of the following statement is correct?
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 these method is used to make a bit zero specified by the index?
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.}
Which of these statements are incorrect?
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 .
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 class object can be used to form a dynamic array?
What is the output of this program?
1.import java.io.*;
2.class files {
3.public static void main(String args[]) {
4.File obj = new File("/java/system");
5.System.out.print(obj.getParent());
6.System.out.print(" " + obj.isFile());
7.}
8.}
Note: file is made in c drive.
Which of these keywords is used to prevent content of a variable from being modified?
Which of these class contains only floating point functions?
Which operator is used to invert all the digits in binary representation of a number?
Which of these values can a boolean variable contain?