Which of these tranfer protocol must be used so that URL can be accessed by URLConnection class object?
What is Truncation is Java?
Which of these can be returned by the operator & ?
Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?
Which of these coding types is used for data type characters in Java?
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.}
Which of these class holds a collection of static methods and variables?
What is the output of this program?
1.class output {
2.public static void main(String args[])
3.{
4.String s1 = "Hello";
5.String s2 = s1.replace('l','w');
6.System.out.println(s2);
7.}
8.}
What is the output of this program?
1.class binary {
2.public static void main(String args[]) {
3.int num = 17;
4.System.out.print(Integer.toBinaryString(num));
5.}
6.}
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. }
What is the output of this program?
1.import java.util.*;
2.class Array {
3.public static void main(String args[]) {
4.int array[] = new int [5];
5.for (int i = 5; i > 0; i--)
6.array[5 - i] = i;
7.Arrays.sort(array);
8.for (int i = 0; i < 5; ++i)
9.System.out.print(array[i]);;
10.}
11.}
What is the output of this program?
1.class Alligator
2.{
3.public static void main(String[] args)
4.{
5.int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
6.int [][]y = x;
7.System.out.println(y[2][1]);
8.}
9.}
What is the output of this program? 1.class average {
2.public static void 3.main(String args[])
3.{
4.double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
5.double result;
6.result = 0;
7.for (int i = 0; i < 6; ++i)
8.result = result + num[i];
9.System.out.print(result/6);
10.}
11. }
What is the output of this program?
1.import java.util.*;
2.class Output {
3.public static void main(String args[]) {
4.TreeSet t = new TreeSet();
5.t.add("3");
6.t.add("9");
7.t.add("1"); 8.t.add("4"); t.add("8");
9.System.out.println(t);
10.}
11.}
-
-
-
-
What is the output of this program?
1.class Abc
2.{
3.public static void .main(String[]args)
4.{
5.String[] elements = { "for", "tea", "too" };
6.String first = (elements.length > 0) ? elements[0]: null;
7.}
8.}
Which of the following statements are incorrect?
Which of these method of HashSet class is used to add elements to its object?
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 World");
6.s1.insert(6 , "Good ");
7.System.out.println(s1);
8.}
9.}
What is the output of this program?
1.class static_out {
2.static int x;
3.static int y;
4.void add(int a, int b){
5.x = a + b;
6.y = x + b;
7.}
8.}
9.class static_use {
10.public static void main(String args[])
11.{
12.static_out obj1 = new static_out();
13.static_out obj2 = new static_out();
14.int a = 2;
15.obj1.add(a, a + 1);
16.obj2.add(5, a);
17.System.out.println(obj1.x + " " + obj2.y);
19.}
20.}
Which of these interface abstractes the output of messages from httpd?
What is the output of this program?
1.class array_output {
2.public static void main(String args[])
3.{
4.int array_variable [] = new int[10];
5.for (int i = 0; i < 10; ++i) {
6.array_variable[i] = i/2;
7.array_variable[i]++;
8.System.out.print(array_variable[i] + " ");
9. i++;
10.}
11.}
12.}
What is the output of this program?
1.class string_class {
2.public static void main(String args[])
3.{
4.String obj = "hello";
5.String obj1 = "world";
6.String obj2 = "hello";
7.System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
8.}
9.}
What is the output of this program?
1.import java.net.*;
2.class networking {
3.public static void main(String[] args) throws MalformedURLException {
5.URL obj = new URL("http://www.sanfoundry.com/javamcq"); System.out.print(obj.toExternalForm());
6.}
7.}
What is the output of this program?
1.class A {
2.public int i;
3.private int j;
4.}
5.class B extends A {
6.void display() {
7.super.j = super.i + 1;
8.System.out.println(super.i + " " + super.j);
9.}
10.}
11.class inheritance {
12.public static void main(String args[])
13.{
14.B obj = new B();
15.obj.i=1;
16.obj.j=2;
17.obj.display();
18.}
19.}
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 {
2public static void main(String args[])
3{
4.String a = "hello i love java";
5.System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
6.}
7.}
Which of these selection statements test only for equality?
Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?
Which of these method of class String Buffer is used to get the length of sequence of characters?
Which keyword is used by method to refer to the object that invoked it?
What is the range of byte data type in Java?
Which of these methods is used to know the full URL of an URL object?
Which of these keywords is used by a class to use an interface defined previously?
Which of these packages contain classes and interfaces used for input & output operations of a program?
What is the value returned by unction compareTo() if the invoking string is less than the string compared?
Which of these is necessary condition for automatic type conversion in Java?
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 method is used to find a URL from the cache of httpd?
Which of these exception is thrown by URL class’s constructors?
What is the numerical range of a char data type in Java?