Which of these can be overloaded?
Which of these can be returned by the operator & ?
Which one is a valid declaration of a boolean?
Which of these is specified by a File object?
What is the output of this program?
1.class operators {
2.public static void main(String args[])
3.{
4.int var1 = 5;
5.int var2 = 6;
6.int var3;
7.var3 = ++ var2 * var1 / var2 + var2;
8.System.out.print(var3);
9.}
10.}
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, 2, b, 1, a.length-2); 6.System.out.print(new String(a) + " " + new String(b));
7.}
8.}
What is the output of this program?
1.class char_increment {
2.public static void main(String args[])
3.{
4.char c1 = 'D';
5.char c2 = 84;
6.c2++;
7.c1++;
8.System.out.println(c1 + " " + c2);
9.}
10.}
Which of these classes implements Set interface?
What is the output of this program?
1.class test {
2.int a;
3.int b;
4.test(int i, int j) {
5.a = i;
6.b = j;
7.}
8.void meth(test o) {
9.o.a *= 2;
10.O.b /= 2;
11.}
12.}
13.class Output {
14.public static void main(String args[])
15.{
16.test obj = new test(10 , 20);
17.obj.meth(obj); 18.System.out.println(obj.a + " " + obj.b); }
19.}
What is the output of this program?
1.import java.util.*;
2.class Linkedlist {
3.public static void main(String args[]) {
4.LinkedList obj = new LinkedList();
5.obj.add("A");
6.obj.add("B");
7.obj.add("C");
8.obj.removeFirst();
9.System.out.println(obj);
10.}
11. }
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.}
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 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;
7.System.out.print(array_variable[i] + " ");
8.i++;
9.}
10.}
11.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.double x = 2.0;
4.double y = 3.0;
5.double z = Math.pow( x, y );
6.System.out.print(z);
7.}
8.}
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);
9.}
10.}
Which of these keywords is used to define packages in Java?
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.}
What is the output of this program?
1.abstract class A {
2.int i;
3.abstract void display();
4.}
5.class B extends A {
6.int j;
7.void display() {
8.System.out.println(j);
9.}
10.}
11.class Abstract_demo {
12. public static void main(String args[])
13.{
14.B obj = new B();
15.obj.j=2;
16.obj.display();
17.}
18.}
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 method of class String is used to remove leading and trailing whitespaces?
Which of the following statements are incorrect?
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 of these method of class String is used to compare two String objects for their equality?
Which of these lines of code will give better performance?
1. a | 4 + c >> b & 7;
2. (a | ((( 4 * c ) >> b ) & 7 ))
Which of these class object has architecture similar to that of array?
Which of these method of Array class is used sort an array or its subset?
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, 2, b, 1, a.length-2); 6.System.out.print(new String(a) + " " + new String(b));
7.}
8.}
What is the output of this program?
1.interface calculate {
2.void cal(int item);
3.}
4.class display implements calculate {
5.int x;
6.public void cal(int item) {
7.x = item * item;
8.}
9.}
10.class interfaces {
11.public static void main(String args[]) {
12.display arr = new display;
13.arr.x = 0;
14.arr.cal(2);
15.System.out.print(arr.x);
16.}
17.}
Which of these standard collection classes implements a dynamic array?
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.}
What will s2 contain after following lines of code?
StringBuffer s1 = “one”;
StringBuffer s2 = s1.append(“two”)
Which of these object stores association between keys and values?
What is the output of this program?
1.class char_increment {
2.public static void main(String args[])
3.{
4.char c1 = 'D';
5.char c2 = 84;
6.c2++;
7.c1++;
8.System.out.println(c1 + " " + c2);
9.}
10.}
What is the output of this program?
1.class increment {
2.public static void main(String args[])
3.{
4.double var1 = 1 + 5;
5.double var2 = var1 / 4;
6.int var3 = 1 + 5;
7.int var4 = var3 / 4;
8.System.out.print(var2 + " " + var4);
9.}
10.}
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.A obj2 = new A();
14.System.out.print(obj1.equals(obj2));
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 is long data type literal?
Which data type value is returned by all transcendental math functions?
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.}
What is the output of this program?
1.import java.net.*;
2.class networking {
3.public static void main(String[] args) throws MalformedURLException {
4.URL obj = new URL("http://www.sanfoundry.com/javamcq");
5.System.out.print(obj.getProtocol());
6.}
7.}