Question 41
MediumWhat is the output of this program?
public class Main {
{
System.out.println( + + + + );
}
}
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What is the output of this program?
public class Main {
{
System.out.println( + + + + );
}
}
3345
3312
15
12345
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
public class Main {
public static void main(String[] args) {
char ch = 'A';
ch += 2;
int n = ch + 1;
System.out.println(ch + " " + n);
}
}
A 66
67 68
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
public class Main {
public static void main(String[] args) {
String s = "a,b,,c";
System.out.println(s.split(",").length);
}
}
3
5
Sign up free to see the answer and a step-by-step explanation.
What is the difference between == and equals() for Java objects?
== cannot be used on objects
They are the same
== compares references; equals() compares content as defined by the class
equals() compares references
Sign up free to see the answer and a step-by-step explanation.
What does the 'final' keyword on a local variable mean in Java?
It is static
It is garbage collected immediately
It can be assigned only once
It is stored on the heap
Sign up free to see the answer and a step-by-step explanation.
Which collection should be used for a thread-safe map with high concurrency in Java?
Hashtable is always better
TreeMap
HashMap
ConcurrentHashMap
Sign up free to see the answer and a step-by-step explanation.
A List<Integer> list holds [10, 20, 30]. What does list.remove(1) remove?
The element at index 1 (20), because remove(int index) is chosen for an int argument
The first element
The element equal to 1
Nothing, since 1 is not in the list
Sign up free to see the answer and a step-by-step explanation.
What happens when Integer x = null; int y = x; runs?
Compilation error
y becomes null
y becomes 0
A NullPointerException during unboxing
Sign up free to see the answer and a step-by-step explanation.
What does the JVM's 'heap' store?
Objects and arrays created with new
The program's source code
Method call frames
Only local primitive variables
Sign up free to see the answer and a step-by-step explanation.
Which Java interface lets a class define its natural ordering for sorting?
Comparable
Iterable
Serializable
Comparator
Sign up free to see the answer and a step-by-step explanation.
C 68
C 67
2
4