Java Test №3

What is the name of the Collection interface used to represent elements in a sequence (in a particular order).
Which of these classes implement the Collection interface SortedMap.
Which statement is true?
What happens when the following program is compiled and run.

public class example
{
int i[] = {0};
public static void main(String args[])
{
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[])
{
int j[] = {2};
i = j;
}
}
Which all lines are part of the output when the following code is compiled and run. Select the three correct answers.

public class test
{
public static void main(String args[])
{
outer :
for(int i = 0; i = 0; j--)
{
if(i == j) break outer;
System.out.println(i + " " + j);
}
}
}
}

a. 0 0
b. 0 1
c. 0 2
d. 0 3
e. 1 0

Which of these statements is true?
Which of the following are true about interfaces.
a. Methods declared in interfaces are implicitly private.
b. Variables declared in interfaces are implicitly public, static, and final.
c. An interface can extend any number of interfaces.
d. The keyword implements indicate that an interface inherits from another.
Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C).
By which class we can read object from stream?
By using which modifier we can prevent from overridden?
Which are true in case of interface?
What gets written on the screen when the following program is compiled and run.

public class test {
public static void main(String args[]) {
int i;
float f = 2.3f;
double d = 2.7;
i = ((int)Math.ceil(f)) * ((int)Math.round(d));

System.out.println(i);
}
}
Which of these statements are true. Select the two correct answers.
a. For each try block there must be at least one catch block defined.
b. A try block may be followed by any number of finally blocks.
c. A try block must be followed by at least one finally or catch block.
d. If both catch and finally blocks are defined, catch block must precede the finally block.
What is the result of compiling and running the following program.

public class test {
public static void main(String args[]) {
String str1="abc";
String str2="def";
String str3=str1.concat(str2);

str1.concat(str2);
System.out.println(str1);
}
}
What are the things we have to follow while creating annotations?
Why we use @Override annotation?
When we go for thread synchronization?
Why @SupressWarning Annotation is used?
What happens if sleep() and wait() executes in synchronized block?
Which are true among below cases?

Kommentieren Sie den Artikel

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

Pruebas en línea