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 value of “d” after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
Which of these is an incorrect Statement?
Which of these method of class String is used to compare two String objects for their equality?
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 standard for communicating multimedia content over email?
Which of these method of String class is used to obtain character at specified index?
What is the value of double constant ‘E’ defined in Math class?
Which of these method is used to change an element in a LinkedList Object
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.}
Which of these methods is used to make raw MIME formatted string?
Which of these is a class which uses String as a key to store the value in object?
Which data type value is returned by all transcendental math functions?
Literals in java must be appended by which of these?
Which of these class can generate an array which can increase and decrease in size automatically?
What is the value stored in x in following lines of code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
What is the output of this program?
1.import java.util.*;
2.class Output {
3.public static void main(String args[]) {
4.ArrayList obj = new ArrayList();
5.obj.add("A");
6.obj.ensureCapacity(3); 7.System.out.println(obj.size());
8.}
9.}
What is the process of defining a method in terms of itself, that is a method that calls itself?
What is the output of this program?
1.class leftshift_operator {
2.public static void main(String args[])
3.{
4.byte x = 64;
5.int i;
6. byte y;
7.i = x << 2;
8.y = (byte) (x << 2)
9.System.out.print(i + " " + y);
10.}
11.}
Which of these class is not related to input and output stream in terms of functioning?
On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?
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.getPort());
6.}
7.}
Which of these method of DatagramPacket is used to find the port number?
Which of these is a super class of wrappers Double & Integer?
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.}
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1? 1. x++;
2. x = x + 1;
3. x += 1;
4. x =+ 1;
Which of these have highest precedence?
What is the output of this program?
1.import java.util.*;
2.class Arraylist {
3.public static void main(String args[]) {
4.ArrayList obj1 = new ArrayList();
5.ArrayList obj2 = new ArrayList();
6.obj1.add("A");
7.obj1.add("B");
8.obj2.add("A");
9.obj2.add(1, "B");
10.System.out.println(obj1.equals(obj2));
11.}
12.}
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.import java.util.*;
2.class Bitset {
3.public static void main(String args[]) {
4.BitSet obj1 = new BitSet(5);
5.BitSet obj2 = new BitSet(10);
6.for (int i = 0; i < 5; ++i)
7.obj1.set(i);
8.for (int i = 3; i < 13; ++i)
9.obj2.set(i);
10.obj1.and(obj2);
11.System.out.print(obj1);
12.}
13.}
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.insert(1,"Java");
6.System.out.println(s1);
7.}
8.}
Which of these keywords is used to define packages in Java?
Which of these classes is not included in java.lang?
Which of the following is a valid declaration of an object of class Box?
Which of these class must be used to send a datatgram packets over a connection?
Which of these class is not a member class of java.io package?
Which of these method of httpd class is used to get report on each hit to HTTP server?
What is the process by which we can control what parts of a program can access the members of a class?
What is the prototype of the default constructor of this class? public class prototype { }
Which of these is a process of writing the state of an object to a byte stream?