Which of the following is correct way of importing an entire package ‘pkg’?
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 A {
2.public int i;
3.protected int j;
4.}
5.class B extends A {
6.int j;
7.void display() {
8.super.j = 3;
9.System.out.println(i + " " + j);
10.}
11.}
12.class Output {
13.public static void main(String args[])
14.{
15. B obj = new B();
16.obj.i=1;
17.obj.j=2;
18.obj.display();
19.}
20.}
Which of these operators is used to allocate memory to array variable in Java?
Which of these are selection statements in Java?
In the below code, which call to sum() method is appropriate?
1.class Output {
2.public static int sum(int ...x)
3.{
4.return;
5.}
6.static void main(String args[])
7.{
8.sum(10);
9.sum(10,20);
10.sum(10,20,30);
11.sum(10,20,30,40);
12.}
13.}
Which of these is returned by “greater than”, “less than” and “equal to” operators
Which of these method is used to change an element in a LinkedList Object
Which of these method of String class can be used to test to strings for equality?
What is the output of this program?
1.package pkg;
2.class output {
3.public static void main(String args[])
4.{
5.StringBuffer s1 = new StringBuffer("Hello");
6.s1.setCharAt(1, x);
7.System.out.println(s1);
8.}
9.}
What is the output of relational operators?
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.s1.setCharAt(1,'x');
6.System.out.println(s1);
7.}
8.}
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 right shift operator preserves the sign of the value?
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.}
Which of the following package stores all the standard java classes?
Which of these methods is used to compare a specific region inside a string with another specific region in another string?
What is the output of this program? 1.class mainclass {
2.public static void main(String args[])
3.{
5.char a = 'A';
5.a++;
6.System.out.print((int)a);
7.}
8.}
Which of these keywords is used by a class to use an interface defined previously?
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.class Output {
2.public static void main(String args[]) {
3.Integer i = new Integer(257);
4.byte x = i.byteValue();
5.System.out.print(x);
6.}
7.}
What is the value of “d” after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
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((char)c);
12.}
13.}
14.}
15.}
16.}
What will be the output of these statement? 1.class output {
2.public static void 3.main(String args[])
4.{
5.double a, b,c;
6.a = 3.0/0;
7.b = 0/4.0;
8.c=0/0.0;
9.System.out.println(a);
10.System.out.println(b);
11.System.out.println(c);
12.}
13.}
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.}
Which of these coding types is used for data type characters in Java?
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 is specified by a File object?
Which of these method Map class is used to obtain an element in the map having specified key?
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 A {
2.final public int calculate(int a, int b) { return 1; }
3.}
4.class B extends A {
5.public int calculate(int a, int b) { return 2; }
6.}
7.public class output {
8.public static void main(String args[])
9.{
10.B object = new B();
11.System.out.print("b is b.calculate(0, 1));
12.}
13.}
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?
Which of these operators is used to allocate memory to array variable 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 of these interface abstractes the output of messages from httpd?
Which of these access specifiers must be used for main() method?
Which of these class is used to access actual bits or content information of a URL?
Which of these is used as default for a member of a class if no access specifier is used for it?
What is the numerical range of a char data type in Java?
Which of these is specified by a File object?