Test your knowledge of core Java concepts
Posted on
July 3, 2017
How much do you know about Oracle's Java programming language?

One of the most popular programming languages of the past few decades is Java. Java, which hit a momentous milestone in 2015, provides the foundation on which so much else is built and makes the web we interact with today possible.

It can be confusing as to what Java actually entails since there are so many add-ons that can be associated with it — not to mention the altogether different JavaScript. To simplify things, and test how well you know the language you likely interact with on a very regular basis, what follows is a self-test of 25 questions all based on the core Java language with topics ranging from trivial to complicated.

The answers appear at the end of the questions. In all cases, pick the best answer(s) to each question. Good luck!

1. Which of the following reads Java code before it runs and makes sure that it obeys basic rules of the language — can't violate access permission on objects, etc.?
A. Class loader
B. Bytecode verifier
C. Java interpreter
D. Sandbox manager

2. Which of the following components of the core Java API lets you write server-side applications?
A. Servlets
B. Beans

3. Which of the following can be used to pass command-line arguments to the application?
A. Command[] strings
B. String[] args
C. $0
D. $1

4. In the code you are writing, it is conceivable the user will type in a value that is a date in a particular field but it could also be a string value. What can you use in Java to work with to "switch" between two types of data?
A. exchange
B. translate
C. convert
D. cast

5. Within Java, the command B++ is the same as which of the following?
A. B = B + B
B. B = B * B
C. B = B + 1
D. B = mod(B)

6. In Java, functions are known as:
A. structures
B. operands
C. methods
D. logics

7. Which of the following operations returns a value of false?
A. 9 ==9
B. 9 <= 9
C. 9 != 9
D. 9 >= 9

8. What is the difference, in Java, between a while loop and a do-while loop?
A. The loop-continuation condition is not checked the first time through the loop.
B. The former existed in earlier versions of Java but has been replaced by the latter in newer versions.
C. The latter only works when a condition is false, while the former only works while the condition is true.
D. There is no difference between the two loops.

9. What value will be returned from the following code:
Math.sqrt(8.0*8.0 - 6.0*8.0)
A. 2
B. 4
C. 16
D. 64

10. Which of the following companies developed Java?
A. Xerox
B. Silicon Graphics International
C. Bell Labs
D. Sun Microsystems

11. With Java, which of the following can be used to find all occurrences of "Sun" but not within "Sunday"?
A. (//Sunday)?Sun
B. (?*Sunday)Sun
C. (?=Sunday)Sun
D. ($!Sunday)Sun

12. Which three of the following are accepted filename extensions in Java (choose three)?
A. .java
B. .jar
C. .class
D. .jav
E. .mod

13. Given the following snippet of code, what is the value of variable B at its conclusion?
String F, S, B;
F = "7";
S = "5";
B = F + S;
A. 75
B. 12
D. null

14. You have just been assigned a new boss who hasn't been directly over programming for some time. He tells you that he would like to see some code changed to include a ternary operator to handle whatever condition the user generates. Within Java, what is the correct coding for this?
A. (condition : result1 : result2 )
B. (condition ? result1 : result2 )
C. (condition ? result1 ? result2 )
D. (condition : result1 ? result2 )

15. Which of the following classes proves the framework for user interface components?
A. JInterface
B. JSwing
C. JComponent
D. JTrue

Please visit GoCertify to attempt the remaining 10 questions of this quiz.


1. B
2. A
3. B
4. D
5. C
6. C
7. C
8. A
9. B
10. D
11. D
12. A, B, and C
13. A
14. B
15. C

About the Author

Emmett Dulaney is a professor at Anderson University and the author of several books including Linux All-in-One For Dummies and the CompTIA Network+ N10-008 Exam Cram, Seventh Edition.

Posted to topic:

Important Update: We have updated our Privacy Policy to comply with the California Consumer Privacy Act (CCPA)

CompTIA IT Project Management - Project+ - Advance Your IT Career by adding IT Project Manager to your resume - Learn More