What is the output of this program? 1.class string_demo {
2.public static void main(String args[])
3.{
4.String obj = "I" + "like" + "Java";
5.System.out.println(obj);
6.}
7.}
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.}
9.}
Which of these method is used to find a URL from the cache of httpd?
What is the output of this program?
1.import java.util.*;
2.class properties {
3.public static void main(String args[]) {
4.Properties obj = new Properties();
5.obj.put("AB", new Integer(3));
6.obj.put("BC", new Integer(2));
7.obj.put("CD", new Integer(8));
8.System.out.print(obj.keySet());
9.}
10.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String s1 = "Hello World";
5.String s2 = s1.substring(0 , 4);
6.System.out.println(s2);
7.}
8.}
What is the output of this program?
1.class A {
2.int i;
3.int j;
4.A() {
5.i = 1;
6.j = 2;
7.}
8.}
9.class Output {
10.public static void main(String args[])
11.{
12.A obj1 = new A();
13.System.out.print(obj1.toString());
14.}
15.}
Which of these can be overloaded?
What is the output of this program?
1.import java.util.*;
2.class Maps {
3.public static void main(String args[]) {
4.HashMap obj = new HashMap(); 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.get("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 class object can be used to form a dynamic array?
Which of these method of Array class is used sort an array or its subset?
What is the name of data member of class Vector which is used to store number of elements in the vector?
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.}
What is the output of this program?
1.class static_out {
2.static int x;
3.static int y;
4.void add(int a , int b){
5.x = a + b;
6.y = x + b;
7.}
8.}
9.class static_use {
10.public static void main(String args[])
11.{
12.static_out obj1 = new static_out();
13.static_out obj2 = new static_out();
14.int a = 2;
15.obj1.add(a, a + 1);
16.obj2.add(5, a);
17.System.out.println(obj1.x + " " + obj2.y);
18.}
19.}
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.}
What is the output of this program?
1.class comma_operator {
2.public static void main(String args[])
3.{
4.int sum = 0;
5.for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
6.sum += i;
7.System.out.println(sum);
8.}
9.}
What is the output of this program?
1.class overload {
2.int x;
3.int y;
4.void add(int a) {
5.x = a + 1;
6.}
7.void add(int a, int b){
8.x = a + 2;
9.}
10.}
11.class Overload_methods {
12.public static void main(String args[])
13.{
14.overload obj = new overload();
15.int a = 0;
16.obj.add(6);
17.System.out.println(obj.x);
18.}
19.}
Which of these classes is used for input and output operation when working with bytes?
What is the process of defining a method in terms of itself, that is a method that calls itself?
Which of these keyword can be used in subclass to call the constructor of superclass?
Which of the following package stores all the standard java classes?
What is the output of this program?
1.package pkg;
2.class display {
3.int x;
4.void show() {
5.if (x > 1)
6.System.out.print(x + " ");
7.}
8.}
9.class packages {
10.public static void main(String args[]) {
11.display[] arr=new display[3];
12.for(int i=0;i<3;i++)
13.arr[i]=new display();
14.arr[0].x = 0;
15.arr[1].x = 1;
16.arr[2].x = 2;
17.for (int i = 0; i < 3; ++i)
18.arr[i].show();
19.}
20.}
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 these is a wrapper for data type int?
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.}
What is the output of this program?
1.class increment {
2.public static void main(String args[])
3.{
4.double var1 = 1 + 5;
5.double var2 = var1 / 4;
6.int var3 = 1 + 5;
7.int var4 = var3 / 4;
8.System.out.print(var2 + " " + var4);
9.}
10.}
What is the output of this program?
1.class String_demo {
2.public static void main(String args[])
3.{
4.int ascii[] = { 65, 66, 67, 68};
5.String s = new String(ascii, 1, 3);
6.ystem.out.println(s);
7.}
8.}
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String c = "Hello i love java";
5.int start = 2;
6.int end = 9;
7.char s[]=new char[end-start];
8.c.getChars(start,end,s,0);
9.System.out.println(s);
10.}
11.}
Which of these class is used for operating on request from the client to the server?
Which of these class can generate an array which can increase and decrease in size automatically?
What is the output of relational operators?
Which of the following is incorrect statement about packages?
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 operators {
2.public static void main(String args[])
3.{
4.int x = 8;
5.System.out.println(++x * 3 + " " + x);
6.}
7.}
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;
7.int d;
8.c = ++b;
9.d = a++;
10.c++;
11.b++;
12.++a;
13.System.out.println(a + " " + b + " " + c);
14.}
15.}
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.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 A {
2.int i;
3.int j;
4.A() {
5.i = 1;
6.j = 2;
7.}
8.}
9.class Output {
10.public static void main(String args[])
11.{
12.A obj1 = new A();
13.A obj2 = new A();
14.System.out.print(obj1.equals(obj2));
15.}
16.}
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 the following statements is correct?