Created
May 15, 2018 13:46
-
-
Save jsbonso/cf52cf28588c53f2c269a265ecf4e184 to your computer and use it in GitHub Desktop.
Compilation of Various Core Java Questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Will two objects with the same hashcode always be equal to each other? | |
A. Yes | |
B. No | |
C. Only when using inheritance | |
D. Two objects can never have the same hashcode | |
2. What does it mean to declare a private method as final? | |
A. It can only be called once. | |
B. It is called upon garbage collection | |
C. A subclass cannot override it | |
D. It is meaningless | |
3. A Java programming language has an enhanced "for" loop, sometimes called the "for each loop". | |
When using it to iterate over a list, what happens if the first element of the list is null? | |
A. An IllegalArgument Exception is thrown before the first iteration | |
B. The iteration ends at the first element. | |
C. A NullPointerException is thrown | |
D. None of the above | |
4. What will happen if a method calls itself without a terminating condition? | |
A. The method with throw StackOverflowError | |
B. The method will throw OutofMemoryError | |
C. The method will throw OutofMemoryException | |
D. The program will run forever | |
5.Can you use mutable objects as the keys in a HashMap? | |
A. Yes, in all cases | |
B. No | |
C. Yes, if you are sure their equals/hash evaluation will not change once inserted into the map. | |
D. Yes, as long as you call map.refresh() | |
6. When invoking a static synchronized method, the monitor of what object is being acquired? | |
A. The Class | |
B. The Object | |
C. The thread | |
D. The method | |
7. What built-in Java factory is used to create thread pools? | |
A. Runnable | |
B. Executors | |
C. ThreadFactory | |
D. ProcessorFactory | |
8. Which of the following is typically associated with Decorator design pattern? | |
A. Composition | |
B. Factory pattern | |
C. Composite pattern | |
D. Multiple inheritance | |
E. None of the above | |
9. In which section of the heap are new objects instantiated? | |
A. First Gen | |
B. Level 0 | |
C. Main | |
D. Eden | |
10. When using Java 7 multi-catch to catch a NullPointerException and ClassCastException as variable 'e', | |
what are the methods available for 'e'? | |
A. Yes | |
B. No | |
C. Only when using inheritance | |
D. Two objects can never have the same hashcode | |
11. Can an anonymous class implement an interface and extend a parent class at the same time? | |
A. No | |
B. Yes, only if it is a lambda expression | |
C. Yes, only if it is final | |
D. Yes, in all cases | |
12. What does the keyword "this" means inside a Java 8 Lambda? | |
A. An instance of the class in which the lambda is defined in | |
B. Will always be null | |
C. It's a syntax error (does not compile) | |
D. An instance of the synthetic anonymous class created for the lambda expression. | |
13. If 's' is a Stream of String withs the months of the year. What woule be the result of s.counts() + s.counts() | |
A. Yes | |
B. No | |
C. Only when using inheritance | |
D. Two objects can never have the same hashcode | |
14. What does Actuator do in Spring? | |
15. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment