What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.Integer i = new Integer(257);
4.float x = i.floatValue();
5.System.out.print(x);
6.}
7.}
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.void print() {
9.system.out.println(" " + y);
10.}
11.}
12.class access_specifier {
13.public static void main(String args[])
14.{
15.access obj = new access();
16.obj.cal(2, 3);
17.System.out.println(obj.x);
18.obj.print();
19.}
20.}
What is the numerical range of a char data type in Java?
Which of these class object can be used to form a dynamic array?
Which of these method is used to find a URL from the cache of httpd?
Which of these methods is used to know host of an URL?
Which of the following operators can operate on a boolean variable? && == ?:
+=
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.}
What is the output of relational operators?
What is the output of this program?
1.import java.io.*;
2.public class filesinputoutput {
3.public static void main(String[] args) {
4.String obj = "abc";
5.byte b[] = obj.getBytes();
6.ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
7.for (int i = 0; i < 2; ++ i) {
8.int c;
9.while ((c = obj1.read()) != -1) {
10.if (i == 0) {
11.System.out.print(Character.toUpperCase((char)c));
12.obj2.write(1);
13.}
14.}
15.System.out.print(obj2);
16.}
17.}
18.}
What is the output of this program?
1.class output {
2.public static void main(String args[]) {
3.StringBuffer sb=new StringBuffer("Hello");
4.sb.replace(1,3,"Java");
5.System.out.println(sb);
6.}
7.}
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 lines of code will give better performance?
1. a | 4 + c >> b & 7;
2. (a | ((( 4 * c ) >> b ) & 7 ))
Which of these is a method of class Date which is used to search weather object contains a date before the specified date?
Which of these method of DatagramPacket is used to find the length of byte array?
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?
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 selection statements test only for equality?
What is the value returned by function compareTo() if the invoking string is greater than the string compared?
What is the output of this program?
1.class test {
2.int a;
3.int b;
4.void meth(int i , int j) {
5.i *= 2;
6.j /= 2;
7.}
8.}
9.class Output {
10.public static void main(String args[])
11.{
12.test obj = new test();
13.int a = 10;
14.int b = 20;
15.obj.meth(a , b);
16.System.out.println(a + " " + b);
17.}
18.}
Which of these is necessary condition for automatic type conversion in Java?
What is the output of this program? 1.class Relational_operator {
2.public static void main(String args[])
3.{
4.int var1 = 5;
5.int var2 = 6;
6.System.out.print(var1 > var2);
7.}
8.}
What is the output of this program?
1.class Output {
2.public static void.main(String args[])
3.{
4.int a = 5;
5.int b = 10;
6.first: {
7.second: {
8.third: {
9.if (a == b >> 1)
10.break second;
11.}
12.System.out.println(a);
13.}
14.System.out.println(b);
15.}
16.}
17.}
Which of these operators can skip evaluating right hand operand?
Which of these coding types is used for data type characters in Java?
Which keyword is used by method to refer to the object that invoked it?
Which of these statements are incorrect?
Which of the following statements are incorrect?
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 error in this code? byte b = 50; b = b * 50;
In below code, what can directly access and change the value of the variable name?
1.package test;
2.class Target
3.{
4.public String name = "hello";
5.}
Which of these method is used to change an element in a LinkedList Object
What is the output of this program?
1.class A {
2.public int i;
3.private int j;
4.}
5.class B extends A {
6.void display() {
7.super.j = super.i + 1;
8.System.out.println(super.i + " " + super.j);
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.}
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 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.}
Which of these keywords can be used to prevent Method overriding?
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.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.int len = obj1.getContentLength();
7.System.out.print(len);
8.}
Note: Host URL is having length of content 127.
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.StringBuffer s2 = s1.reverse();
6.System.out.println(s2);
7.}
8.}
What is the output of this program?
1.import java.io.*;
2.public class filesinputoutput {
3.public static void main(String[] args) {
4.String obj = "abc";
5.byte b[] = obj.getBytes();
6.ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
7.for (int i = 0; i < 2; ++ i) {
8.int c;
9.while ((c = obj1.read()) != -1) {
10.if (i == 0) {
11.System.out.print(Character.toUpperCase((char)c));
12.}
13.}
14.}
15.}
16.}