Which of these keywords cannot be used for a class which has been declared final?
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 c = new StringBuffer("Hello");
5.System.out.println(c.length());
6. }
7. }
Which of these data type is returned by every method of OutputStream?
Which of these classes implements Set interface?
In below code, what can directly access and change the value of the variable name?
1.package test;
2.class Target
3.{
4.public String name = "hello";
5.}
What is the output of this program? 1.class Output {
2.public static void main(String args[]) {
3.long start, end;
4.start = System.currentTimeMillis();
5.for (int i = 0; i < 10000000; i++);
6.end = 7.System.currentTimeMillis();
System.out.print(end - start);
8.}
9.}
Which of these methods must be made static?
Which of these methods is used to know the full URL of an URL object?
Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String s1 = "one";
5.String s2 = s1 + " two";
6.System.out.println(s2);
7.}
8.}
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.}
What is the output of this program?
1.class variable_scope {
2.public static void main(String args[])
3.{
4.int x;
5.x = 5;
6.{
7.int y = 6;
8.System.out.print(x + " " + y);
9.}
10.System.out.println(x + " " + y);
11.}
12.}
Arrays in Java are implemented as?
Which of these method is used to make all elements of an equal to specified value?
Which of these access specifiers can be used for an interface?
Which of the following statements are incorrect?
Which of the following is correct way of importing an entire package ‘pkg’?
Which of these methods is used to retrieve elements in BitSet object at specific location?
Which of these class contains only floating point functions?
What is the value returned by unction compareTo() if the invoking string is less than the string compared?
What will s2 contain after following lines of code?
String s1 = “one”;
String s2 = s1.concat(“two”)
Which of these methods is used to add elements in vector at specific location?
Which of these is method for testing whether the specified element is a file or a directory?
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.}
Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
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.StringBuffer c1 = new StringBuffer(" World");
6.c.append(c1);
7.System.out.println(c);
8.}
9. }
Which method can be defined only once in a program?
Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
Which of these methods is used to check for infinitely large and small values?
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.}
Which of these method of class StringBuffer is used to find the length of current character sequence?
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 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.}
Which of these class is not a member class of java.io package?
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;
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.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.}
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.canWrite());
6.System.out.print(" " + obj.canRead());
7.}
8.} Note: file is made in c drive.