Test : Java_14
This test contains 10 questions based on Java.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Each question answered correctly awards you 1 point and each incorrect answer has a penalty of -0.25 points, no points are deducted for unattempted answers.
Select Test Type
You Get +1 for each correct answer and -0.25 for each incorrect answer
Time Left - minutes :seconds
Which of these interface is implemented by Thread class?
| Runnable | Connections |
| Set | MapConnections |
What is the output of this program?
class area {
int width;
int length;
int area;
void area(int width, int length) {
this.width = width;
this.length = length;
}
}
class Output {
public static void main(String args[])
{
area obj = new area();
obj.area(5 , 6);
System.out.println(obj.length + " " + obj.width);
}
}| 0 0 | 5 5 |
| 5 6 | 6 5 |
What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3
| Integer | Floating ? point numbers |
| Boolean | None of the mentioned |
Which of these interface handle sequences?
| Set | List |
| Comparator | Collection |
Which of these is an incorrect form of using method max() to obtain maximum element?
| max(Collection c) | max(Collection c, Comparator comp) |
| max(Comparator comp) | max(List c) |
What is the output of this program?
class string_class {
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
| hello hello | world world |
| hello world | world hello |
Which of these operators can be used to get run time information about an object?
| getInfo | Info |
| instanceof | getinfoof |
Which of these keywords is used to make a class?
| class | struct |
| int | None of the mentioned |
Which of these method of class String is used to check weather a given object starts with a particular string literal?
| startsWith() | endsWith() |
| Starts() | ends() |
What is the output of this program?
class output {
public static void main(String args[])
{
String chars[] = {"a", "b", "c", "a", "c"};
for (int i = 0; i < chars.length; ++i)
for (int j = i + 1; j < chars.length; ++j)
if(chars[i].compareTo(chars[j]) == 0)
System.out.print(chars[j]);
}
}| ac | ca |
| ab | ba |
Finish Test
No comments: