Java Test №1

Which declaration of the main method below would allow a class to be started as a standalone program.

What is the meaning of the return data type void?

Which of these are legal identifiers.

Which of the following are Java keywords?

A lower precision can be assigned to a higher precision value in Java. For example a byte type data can be assigned to int type.

Which of these are not legal identifiers.

Which of the following are legal definitions of the main method that can be used to execute a class.

Which of the following statements about the Java language is true?

Which of the following are keywords in Java.

Which of these are legal array declarations or definitions?

What gets printed when the following code is compiled and run with the following command – java test 2 Select the one correct answer.



public class test {
public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
int i = intObj.intValue();

if(args.length > 1)
System.out.println(i);
if(args.length > 0)
System.out.println(i – 1);
else
System.out.println(i – 2);
}
}

Which of the following statements is false about objects?

Which of these are legal identifiers.


a. number_1
b. number_a
c. $1234
d. -volatile

The class Hashtable is used to implement which collection interface. Select the one correct answer.

TreeMap class is used to implement which collection interface. Select the one correct answer.

Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer.

What happens when the following code is compiled and run. Select the one correct answer.


for(int i = 1; i i; j–)
assert i!=j {System.out.println(i); }

What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.


protected class example {
public static void main(String args[]) {
String test = "abc";
test = test + test;
System.out.println(test);
}
}

In the following class definition, which is the first line (if any) that causes a compilation error. Select the one correct answer.


public class test {
public static void main(String args[]) {
char c;
int i;
c = 'A'; // 1
i = c; //2
c = i + 1; //3
c++; //4
}
}

Which of the following is a Java keyword.
a. extern
b. synchronized
c. volatile
d. friend
e. friendly
f. transient
g. this
h. then

Kommentieren Sie den Artikel

Bitte geben Sie Ihren Kommentar ein!
Bitte geben Sie hier Ihren Namen ein

Pruebas en línea