Which of these methods is used to compare a specific region inside a string with another specific region in another string?
What is the return type of a method that does not returns any value?
What is the output of this program?
1.class evaluate {
2.public static void main(String args[])
3.{
4.int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
5.int n = 6;
6.n = arr[arr[n] / 2];
7.System.out.println(arr[n] / 2);
8.}
9.}
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 method of class String is used to compare two String objects for their equality?
Which of these is used as default for a member of a class if no access specifier is used for it?
Which of these access specifiers must be used for main() method?
What is the output of this program?
1.class area {
2.int width;
3.int length;
4.int volume;
5.area() {
6.width=5;
7.length=6;
8.}
9.void volume() {
1o.volumewidth*length*height;
11.}
12.}
13.class cons_method {
14.public static void main(String args[])
15.{
16.area obj = new area();
17.obj.volume();
18.System.out.println(obj.volume);
19.}
20}
Which of these have highest precedence?
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 method of Object class can generate duplicate copy of the object on which it is called?
Which of these class is used for operating on request from the client to the server?
What is the output of this program?
1.class evaluate {
2.public static void main(String args[])
3.{
4.int a[] = {1,2,3,4,5};
5.int d[] = a;
6.int sum = 0;
7.for (int j = 0; j < 3; ++j)
8.sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
9.System.out.println(sum);
10.}
11.}
What is process of defining two or more methods within same class that have same name but different parameters declaration?
Which of these methods can be used to obtain set of all keys in a map?
Which of these method of Object class can clone an object?
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.}
Which of the following is correct way of importing an entire package ‘pkg’?
Which of the following is incorrect statement about packages?
Which of these access specifiers must be used for main() method?
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.}
What is the output of this program?
1.import java.util.*;
2.class Bitset {
3.public static void main(String args[]) {
4.BitSet obj = new BitSet(5);
5.for (int i = 0; i < 5; ++i)
6.obj.set(i);
7.obj.clear(2);
8.System.out.print(obj.length() + " " + obj.size());
9.}
10.}
Which of the following statements are incorrect?
What is the output of this program?
1.class box {
2.int width;
3.int height;
4.int length;
5.int volume;
6.void finalize() {
7.volume = width*height*length;
8.System.out.println(volume);
9.}
10.protected void volume() {
11.volume = width*height*length;
12.System.out.println(volume);
13.}
14.}
15.class Output {
16.public static void main(String args[])
17.{
18.box obj = new box();
19.obj.width=5;
20.obj.height=5;
21.obj.length=6;
22.obj.volume();
23.}
24.}
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.getProtocol());
6.}
7.}
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 these tranfer protocol must be used so that URL can be accessed by URLConnection class object?
At line number 2 below, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
public interface Status
{
/* insert qualifier here */ int MY_VALUE = 10;
}
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.
Which of these is an incorrect array declaration?
Which of these class is used to create an object whose character sequence is mutable?
Which of these is incorrect string literal?
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.getProtocol());
6.}
7.}
What is the output of this program?
1.class ternary_operator {
2.public static void .main(String args[])
3.{
4.int x = 3;
5.int y = ~ x;
6.int z;
7.z = x > y ? x : y;
8.System.out.print(z);
9.}
10.}
What is the output of this program?
1.class selection_statements {
2. public static void main(String args[])
3.{
4.int var1 = 5;
5.int var2 = 6;
6.if ((var2 = 1) == var1)
7.System.out.print(var2);
8.else
9.System.out.print(++var2);
10.}
11.}
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.}
What is the output of this program?
1.import java.util.*;
2.class Bitset {
3.public static void main(String args[]) {
4.BitSet obj = new BitSet(5);
5.for (int i = 0; i < 5; ++i)
6.obj.set(i);
7.System.out.print(obj.get(3));
8.}
9.}
Which of the following statements are incorrect?
Which of these class is used to create servers that listen for either local or remote client programs?
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.StringBuffer s1 = new StringBuffer("Hello World");
5.s1.insert(6 , "Good ");
6.System.out.println(s1);
7.}
8.}