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 obj1 = new box();
10.box obj2 = new box();
11.obj1.height = 1;
12.obj1.length = 2;
13.obj1.width = 1;
14.obj2 = obj1;
15.System.out.println(obj2.height);
16.}
17.}
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 Output {
3.public static void main(String args[]) {
4.ArrayList obj = new ArrayList();
5.obj.add("A");
6.obj.ensureCapacity(3); 7.System.out.println(obj.size());
8.}
9.}
What is the output of this program?
1.class A {
2.public int i;
3.protected int j;
4.}
5.class B extends A {
6.int j;
7.void display() {
8.super.j = 3;
9.System.out.println(i + " " + j);
10.}
11.}
12.class Output {
13.public static void main(String args[])
14.{
15. B obj = new B();
16.obj.i=1;
17.obj.j=2;
18.obj.display();
19.}
20.}
Which of these is an on correct statement?
What is the output of this program?
1.class output {
2public static void main(String args[])
3{
4.String a = "hello i love java";
5.System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
6.}
7.}
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.System.out.println(c.length());
6. }
7. }
What is the output of this program?
1.class Output {
2.public static void 3.main(String args[])
4.{
5.int x=y=z=20;
6.}
7.}
What is the order of precedence (highest to lowest) of following operators?
1. &
2. ^
3. ?:
What is the output of this program?
1.import java.util.*;
2.class Output {
3.public static void main(String args[]) {
4.ArrayList obj = new ArrayList();
5.obj.add("A");
6.obj.add(0, "B");
7.System.out.println(obj.size());
8.}
9.}
Which of these is not a bitwise operator?
What is the output of this program?
1.package pkg;
2.class output {
3.public static void main(String args[])
4.{
5.StringBuffer s1 = new StringBuffer("Hello");
6.s1.setCharAt(1, x);
7.System.out.println(s1);
8.}
9.}
What is the output of this program?
1.class A {
2.final public int calculate(int a, int b) { return 1; }
3.}
4.class B extends A {
5.public int calculate(int a, int b) { return 2; }
6.}
7.public class output {
8.public static void main(String args[])
9.{
10.B object = new B();
11.System.out.print("b is b.calculate(0, 1));
12.}
13.}
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.}
Which of these class have only one field ‘TYPE’?
What will be the output of these statement? 1.class output {
2.public static void 3.main(String args[])
4.{
5.double a, b,c;
6.a = 3.0/0;
7.b = 0/4.0;
8.c=0/0.0;
9.System.out.println(a);
10.System.out.println(b);
11.System.out.println(c);
12.}
13.}
Which of these classes provide implementation of map interface?
Which of these class encapsulate the run time state of an object or an interface?
What is the output of this program?
1.class isinfinite_output {
2.public static void main(String args[]) {
3.Double d = new Double(1 / 0.);
4.boolean x = d.isInfinite();
5.System.out.print(x);
6.}
7.}
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 increment {
2.public static void main(String args[])
3.{
4.int g = 3;
5.System.out.print(++g * 8);
6.}
7.}
Which of these class object uses key to store value?
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 = 3;
7.a |= 4;
8.b >>= 1;
9. c <<= 1;
10.a ^= c;
11.System.out.println(a + " " + b + " " + c);
12.}
13.}
Which of these method Map class is used to obtain an element in the map having specified key?
What is the output of relational operators?
What is the output of this program?
1.class access{
2.public int x;
3.static int y;
4.void cal(int a, int b){
5.x += a ;
6.y += b;
7.}
8.}
9.class static_specifier {
10.public static void main(String args[])
11.{
12.access obj1 = new access();
13.access obj2 = new access();
14.obj1.x = 0;
15.obj1.y = 0;
16.obj1.cal(1, 2);
17.obj2.x = 0;
18.obj2.cal(2, 3);
19.System.out.println(obj1.x + " " + obj2.y);
20.}
21.}
Which of these keyword must be used to inherit a class?
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.}
Which of these class relies upon its subclasses for complete implementation of its methods?
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.char a[] = {'a', '5', 'A', ' '};
4.System.out.print(Character.isDigit(a[0]) + " ");
5.System.out.print(Character.isWhitespace(a[3]) + " "); 6.System.out.print(Character.isUpperCase(a[2]));
7.}
8.}
What is the output of this program?
1.class area {
2.int width;
3.int length;
4.int area;
5.void area(int width, int length) {
6.this.width = width;
7.this.length = length;
8.}
9.}
10.class Output {
11.public static void main(String args[])
12.{
13.area obj = new area();
14.obj.area(5 , 6);
15.System.out.println(obj.length + " " + obj.width);
16.}
17.}
Which of these process occur automatically by java run time system?
Which of these class is not related to input and output stream in terms of functioning?
Which of these method of class String is used to remove leading and trailing whitespaces?
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.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.}
Which of these tranfer protocol must be used so that URL can be accessed by URLConnection class object?
Which of these standard collection classes implements a linked list data structure?
What is the output of this program?
1.class access{
2.public int x;
3.private int y;
4.void cal(int a, int b){
5.x = a + 1;
6.y = b;
7.}
8.}
9.class access_specifier {
10.public static void main(String args[])
11.{
12.access obj = new access();
13.obj.cal(2, 3);
14.System.out.println(obj.x + " " + obj.y);
15.}
16.}
Which of these keyword can be used in subclass to call the constructor of superclass?