What is the output of this program?
1.class c {
2.public void main( String[] args )
3.{
4.System.out.println( "Hello" + args[0] );
5.}
6.}
Which of these method is used to remove all keys/values pair from the invoking map?
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 object has architecture similar to that of array?
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.
Which of the following statements are incorrect?
What is the output of this program? 1.class average {
2.public static void 3.main(String args[])
3.{
4.double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
5.double result;
6.result = 0;
7.for (int i = 0; i < 6; ++i)
8.result = result + num[i];
9.System.out.print(result/6);
10.}
11. }
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.c.delete(0,2);
6.System.out.println(c);
7.}
8.}
Which of these are selection statements in Java?
What is the return type of Constructors?
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.}
Which of these is incorrect string literal?
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.length() + " " + obj.size());
9.}
10.}
Which of these variables stores the number of hits that are successfully served out of cache?
Which of these class is used to read and write bytes in a file?
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.}
Which of these classes implements Set interface?
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 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 box {
2.int width;
3.int height;
4.int length;
5.int volume;
6.box() {
7.width = 5;
8.height = 5;
9.length = 6;
10.}
11.void volume() {
12.volume = width*height*length;
13.}
14.}
15.class constructor_output {
16.public static void main(String args[])
17.{
18.box obj = new box();
19.obj.volume();
20.System.out.println(obj.volume);
21.}
22.}
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 output of this program?
1.class ternary_operator {
2.public static void .main(String args[])
3.{
4.int x = 3;
5.int y = ~ x;
6.int z;
7.z = x > y ? x : y;
8.System.out.print(z);
9.}
10.}
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
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.import java.util.*;
2.class Bitset {
3.public static void main(String args[]) {
4.BitSet obj1 = new BitSet(5);
5.BitSet obj2 = new BitSet(10);
6.for (int i = 0; i < 5; ++i)
7.obj1.set(i);
8.for (int i = 3; i < 13; ++i)
9.obj2.set(i);
10.obj1.and(obj2);
11.System.out.print(obj1);
12.}
13.}
What is the range of byte data type in Java?
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.}
Which of these coding types is used for data type characters in Java?
On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?
What is the output of this program?
1.class Output {
2.public static void main(String args[])
3.{
4.int a,b,c,d;
5.a=b=c=d=20
6.a+=b-=c*=d/=20 7.System.out.println(a+" 8."+b+" "+c+" "+d);
9.}
10.}
Which of these class is superclass of every class in Java?
Which of these values can a boolean variable contain?
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 .
Which of these methods is used to add elements in vector at specific location?
What does URL stands for?
Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
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 of class String is used to compare two String objects for their equality?
Which of the following statements are incorrect?
What is the output of this program? 1.class average {
2.public static void 3.main(String args[])
3.{
4.double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
5.double result;
6.result = 0;
7.for (int i = 0; i < 6; ++i)
8.result = result + num[i];
9.System.out.print(result/6);
10.}
11. }