Answer: C
The operator || is undefined for the argument type(s) int, boolean
5. Given the program
What become the output?
A. null
B. life
C. universe
D. everything
E. Compilation fails.
F. An exception is thrown at runtime.
Answer:
-> D is correct. This is a ternary nested in a ternary with a little unboxing thrown in.
Both of the ternary expressions are false.
-> A, B, C, E, and F are incorrect based on the above.
6. Given the program
Which, inserted independently at line 5, will compile? (Choose all that apply.)
A. b = (Number instanceof s);
B. b = (s instanceof Short);
C. b = s.instanceof(Short);
D. b = (s instanceof Number);
E. b = s.instanceof(Object);
F. b = (s instanceof String);
Answer:
-> B and D correctly use boxing and instanceof together.
-> A is incorrect because the operands are reversed. C and E use incorrect instance of syntax. F is wrong because Short isn't in the same inheritance tree as String.
I have over 7+ years of experience as a technical lead and have worked at both small startups and large organizations. While I'm a proficient full-stack developer, my expertise is in building scalable backend micro-services (API, Services, Data processing, async processing, multi-threaded services and data analysing) and build the client side UI (single page angular/react applications, Multiplatform rendering using bootstrap or material).
No comments:
Post a Comment