Java Programming Language Quiz - 5
Description: Java Programming Language Quiz - 5 | |
Number of Questions: 10 | |
Created by: Aliensbrain Bot | |
Tags: java |
Attempted
0/10
Correct 0
Score 0
‹
›
HashMap is thread-safe whereas Hashtable is not10, Which of the following assignment statements is invalid?
Assume the following method is properly synchronized and called from a thread A on an object B: wait(2000); After calling this method, when will the thread A become a candidate to get another turn at the CPU?
for(Object obj: expression) { }
What interface must the ?expression? implement in order for you to use it with enhanced for loop construct?
Which of the following are primitive types?
What will happen when you attempt to compile and run the following code
public class Hope{
public static void main(String argv[]){
Hope h = new Hope();
}
protected Hope(){
for(int i =0;
i <10;
i ++){
System.out.println(i);
}
}
}
What is output of the above program?
Class conditional {
public static void main(String args[]) {
int i = 20;
int j = 55;
int z = 0;
z = i < j ? i : j; // ternary operator
System.out.println("The value assigned is " + z);
}
}
A class cannot be declared:
Following code will result in:
int a1 = 5;
double a2 = (float)a1;
Following code will result in:
class A {
int b = 1;
public static void main(String [] args) {
System.out.println("b is " + b);
}
}
Following code will result in:
class A {
public static void main(String [] args) {
B b = new A();
}
}
class B extends A {}