What is the output of this program?
1.import java.io.*;
2.class filesinputoutput {
3.public static void main(String args[]) {
4.InputStream obj = new FileInputStream("inputoutput.java"); 5.System.out.print(obj.available());
6.}
7.}
Note: inputoutput.java is stored in the disk.
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.}
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.}
Which of these is a super class of wrappers Long, Character & Integer?
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 coding types is used for data type characters in Java?
Which method can be defined only once in a program?
What is the output of this program?
1.class string_class {
2.public static void main(String args[])
3.{
4.String obj = "I LIKE JAVA";
5.System.out.println(obj.length());
6.}
7.}
Which of these methods is used to add elements in vector at specific location?
Which of these is a process of converting a simple data type into a class?
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.}
What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.StringBuffer s1 = new StringBuffer("Hello World");
5.s1.insert(6 , "Good ");
6.System.out.println(s1);
7.}
8.}
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.String c = " Hello World ";
5.String s = c.trim();
6.System.out.println("\""+s+"\"");
7.}
8.}
Which of these are selection statements in Java?
Which of these method is used to calculate number of bits required to hold the BitSet object?
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/2;
7.array_variable[i]++;
8.System.out.print(array_variable[i] + " ");
9. i++;
10.}
11.}
12.}
Which of these methods is used to retrieve elements in BitSet object at specific location?
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 these is correct way of calling a constructor having no parameters, of superclass A by subclass B?
Which of these methods is used to check for infinitely large and small values?
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.}
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.}
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 these keywords is used to define interfaces in Java?
Which of these class holds a collection of static methods and variables?
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.}
Which of these method is used to add an element to the start of a LinkedList object?
Which method can be defined only once in a program?
Which of these class is used to access actual bits or content information of a URL?
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.}
Which of these class is used to encapsulate IP address and DNS?
What is the output of this program? 1.class Output {
2.public static void main(String args[])
3.{
4.boolean a = true;
5.boolean b = false;
6.boolean c = a ^ b;
7.System.out.println(!c);
8.}
9.}
Which of the following statements are incorrect?
What is the output of this program?
1.class operators {
2.public static void main(String args[])
3.{
4.int x = 8;
5.System.out.println(++x * 3 + " " + x);
6.}
7.}
Which of these methods can be used to convert all characters in a String into a character array?
Which operator is used to invert all the digits in binary representation of a number?
Which of these is an incorrect Statement?
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.}