What is the return type of Constructors?
Which of these method is used to start a server thread?
Which of these method of class String is used to extract a substring from a String object?
Which of these statement is correct?
What is the output of this program?
1.import java.util.*;
2.class Output {
3.public static void main(String args[]) {
4.HashSet obj = new HashSet();
5.obj.add("A");
6.obj.add("B");
7.obj.add("C");
8.System.out.println(obj + " " + obj.size());
9}
10.}
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, 7);
17.System.out.println(obj.x);
18.}
19.}
Which of these classes provide implementation of map interface?
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 is a method having same name as that of it’s class?
What is the value returned by function compareTo() if the invoking string is greater than the string compared?
Which of these method of class String is used to extract a single character from a String object?
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.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.class output {
2.public static void main(String args[])
3.{
4.String a = "hello i love java";
5.System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
6.}
7.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.StringBuffer s1 = new StringBuffer("Hello");
5.s1.insert(1,"Java");
6.System.out.println(s1);
7.}
8.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String s1 = "Hello World";
5.String s2 = s1.substring(0 , 4);
6.System.out.println(s2);
7.}
8.}
Which of these methods is used to obtain value of invoking object as a long?
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int a = 1;
5.int b = 2;
6.int c;
7.int d;
8.c = ++b;
9.d = a++;
10.c++;
11.b++;
12.++a;
13.System.out.println(a + " " + b + " " + c);
14.}
15.}
Which of these class is not related to input and output stream in terms of functioning?
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 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.}
Which of these method is used to calculate number of bits required to hold the BitSet object?
Which of these keywords is used to refer to member of base class from a sub class?
What is the output of this program?
1.class box {
2.int width;
3.int height;
4.int length;
5.int volume;
6.void volume(int height, int length, int width) {
7.volume = width*height*length;
8.}
9.}
10.class Prameterized_method{
11.public static void main(String args[])
12.{
13.box obj = new box();
14.obj.height = 1;
15.obj.length = 5;
16.obj.width = 5;
17.obj.volume(3,2,1);
18.System.out.println(obj.volume);
19.}
20.}
Which of these class is used to create servers that listen for either local or remote client programs?
What is the output of this program? 1.class booloperators {
2.public static void .main(String args[])
3.{
4.boolean var1 = true;
5.boolean var2 = false;
6.System.out.println((var2 & var2));
7.}
8.}
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.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.Integer i = new Integer(257);
4.byte x = i.byteValue();
5.System.out.print(x);
6.}
7.}
What is the output of this program?
1.class equality {
2.int x;
3.int y;
4.boolean isequal(){
5.return(x == y);
6.}
7.}
8.class Output {
9.public static void main(String args[])
10.{
11.equality obj = new equality();
12.obj.x = 5;
13.obj.y = 5;
14.System.out.println(obj.isequal());
15.}
16.}
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 data member of HttpResponse class is used to store the response from a http server?
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(5)); 8.System.out.println(obj.elementAt(1));
9.}
10.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3. {
4.StringBuffer c = new StringBuffer("Hello");
5.StringBuffer c1 = new StringBuffer(" World");
6.c.append(c1);
7.System.out.println(c);
8.}
9. }
Which of these method is used to make all elements of an equal to specified value?
Which of these method of class String is used to check weather a given object starts with a particular string literal?
Which of these keywords is used by a class to use an interface defined previously?
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int a1[] = new int[10];
5.int a2[] = {1, 2, 3, 4, 5}; 6.System.out.println(a1.length + " " + a2.length);
7.}
8.}
What is the output of this program?
1.class A {
2.public int i;
3.public int j;
4. A() {
5.i = 1;
6.j = 2;
7.}
8. }
9.class B extends A {
10.int a;
11. B() {
12.super();
13.}
14.}
15.class super_use {
16.public static void main(String args[])
17.{
18.B obj = new B();
19.System.out.println(obj.i + " " + obj.j)
20.}
21.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.byte a[] = { 65, 66, 67, 68, 69, 70 };
4.byte b[] = { 71, 72, 73, 74, 75, 76 };
5.System.arraycopy(a , 0, b, 0, a.length);
6.System.out.print(new String(a) + " " + new String(b));
7.}
8.}
Which of the following statements are incorrect?