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 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.}
Which of these method of class String is used to compare two String objects for their equality?
Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Which of these classes is not included in java.lang?
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 the following is method of System class is used to find how long a program takes to execute?
What is the value stored in x in following lines of code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
Which of these object stores association between keys and values?
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?
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.}
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.contains(new Integer(5)));
9.}
10.}
Which of these class is superclass of every class in Java?
What is the string contained in s after following lines of code?
StringBuffer s new StringBuffer(“Hello”);
s.deleteCharAt(0);
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 method of ArrayList class is used to obtain present size of an object?
Which of these class is not related to input and output stream in terms of functioning?
What is the output of this program?
1.import java.util.*;
2.class Output {
3.public static void main(String args[]) {
4.HashSet obj = new HashSet();
5.obj.add("A");
6.obj.add("B");
7.obj.add("C");
8.System.out.println(obj + " " + obj.size());
9}
10.}
Which of these method is used to change an element in a LinkedList Object
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.
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.}
What is the output of this program?
1.import java.util.*;
2.class Maps {
3.public static void main(String args[]) { 4.TreeMap obj = new TreeMap();
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.entrySet());
9.}
10.}
Which of these methods is used to make raw MIME formatted string?
What is the output of this program?
1.import java.io.*;
2.class files {
3.public static void main(String args[]) {
4.File obj = new File("/java/system");
5.System.out.print(obj.getName());
6.}
7.}
Which of these are selection statements in Java?
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.}
Which one is a valid declaration of a boolean?
Which of these methods is used to retrieve elements in BitSet object at specific location?
What is the output of this program?
1.class Modulus {
2. public static void main(String args[])
3.{
4.double a = 25.64;
5.int b = 25;
6.a = a % 10;
7.b = b % 10;
8.System.out.println(a + " " + b);
9.}
10.}
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 method of class String is used to obtain length of String object?
Which of these class is used to read and write bytes in a file?
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 method of class String is used to extract a single character from a String object?
Which of these statements are incorrect?
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.}
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() {
volume = 7.width*height*length;
8.}
9.}
10.class Output {
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();
18.System.out.println(obj.volume);
19.}
20.}
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 will be output of the following code?
1.public class Boxer1 {
2.Integer i;
3. int x;
4.public Boxer1(int y) {
5.x = i+y;
6.System.out.println(x);
7.}
8.public static void main(String[] args) {
9. new Boxer1 (new Integer(4));
10.}
11.}
What is the output of this program?
1.import java.util.*;
2.class Array {
3.public static void main(String args[]) {
4.int array[] = new int [5];
5.for (int i = 5; i > 0; i--)
6.array[5-i] = i;
7.Arrays.fill(array, 1, 4, 8);
8.for (int i = 0; i < 5 ; i++)
9.System.out.print(array[i]);
10.}
11.}