What is the output of this program?
1.import java.util.*;
2.class stack {
3.public static void main(String args[]) {
4.Stack obj = new Stack();
5.obj.push(new Integer(3));
6.obj.push(new Integer(2));
7.obj.pop();
8.obj.push(new Integer(5));
9.System.out.println(obj);
10.}
11.}
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.double x = 3.1;
4.double y = 4.5;
5.double z = Math.max( x, y );
6.System.out.print(z);
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 is supported by method overriding in Java?
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 the following statements are incorrect?
Which of the following package stores all the standard java classes?
What is the output of this program?
1.class Output {
2.public static void main(String args[]) {
3.byte a[] = { 65, 66, 67, 68, 69, 70 };
4.byte b[] = { 71, 72, 73, 74, 75, 76 };
5.System.arraycopy(a, 1, b, 3, 0);
6.System.out.print(new String(a) + " " + new String(b));
7.}
8.}
Which of these statement is incorrect?
Which of these can be returned by the operator & ?
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.}
Which of the following is method of wrapper Float for converting the value of an object into byte?
Which of the following is correct way of implementing an interface salary by class manager?
What is the output of this program? 1.class array_output {
2.public static void main(String args[])
3.{
4.char array_variable [] = new char[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 the following is incorrect statement about packages?
What is the output of this program?
1.class isNaN_output {
2.public static void main(String args[]) {
3.Double d = new Double(1 / 0.);
4.boolean x = d.isNaN();
5.System.out.print(x);
6.}
7.}
A class member declared protected becomes member of subclass of which type?
Which of these keywords is used to define packages in Java?
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.}
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.}
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.}
An expression involving byte, int, and literal numbers is promoted to which of these?
Which of these have highest precedence?
Which of these class is superclass of all other classes?
Which of these statements are incorrect?
Which of these classes provide implementation of map interface?
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.getHost());
6}
7.}
Decrement operator, −−, decreases value of variable by what number?
Which of these packages contain classes and interfaces used for input & output operations of a program?
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.import java.util.*;
2.class Arraylist {
3.public static void main(String args[]) {
4.ArrayList obj = new ArrayList();
5.obj.add("A");
6.obj.add("B");
7.obj.add("C");
8.obj.add(1, "D");
9.System.out.println(obj);
10.}
11.}
-
-
-
-
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 is used to find a URL from the cache of httpd?
Which of the following are legal lines of Java code? 1. int w = (int)888.8; 2.byte x = (byte)100L; 3.long y = (byte)100; 4.byte z = (byte)100L;
Which data type value is returned by all transcendental math functions?
What is process of defining two or more methods within same class that have same name but different parameters declaration?
What is the output of this program?
1.import java.util.*;
2.class Linkedlist {
3.public static void main(String args[]) {
4.LinkedList obj = new LinkedList();
5.obj.add("A");
6.obj.add("B");
7.obj.add("C");
8.obj.removeFirst();
9.System.out.println(obj);
10.}
11. }
Literal can be of which of these data types?
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String a = "hello i love java";
5.System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
6.}
7.}
Which of these keywords cannot be used for a class which has been declared final?