Basic Java Online Test Questions and Answers

Basic Java Online Test

Take Basic Java Online Test and evaluate your readiness before you appear for any interview or written test. Consisting of objective type questions from various important concepts of Basic Java, this test presents you questions followed by four options. The correct answer, explanation and example provided with each question make it easier for you to understand each concept well.

Who is this Basic Java Online Test designed for?

All the Developers, Programmers, Front End developers, UI/ UX developers and designers will find this test extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in IT field will be highly benefited by this test.

Basic Java Online Test topics

This online test covers topics like - main method, return data type, identifiers, keywords, class, object, constructor, access modifier etc.
1. Which of the following legal definition of the main method that allows a standalone Java application to run?

a. public static void main(String args[])
b. public static int main(char args[])
c. public static void main(String args)
d. public static void MAIN(String args[])

Answer: a. public static void main(String args[])


2. Explain the return data type void in Java.

a. void is not supported in Java
b. void returns no data type  
c. void is used when you do not want your function to return anything.
d. Both b and c

Answer: d. Both b and c


3. Which of the following are legal identifiers in Java?

a. roll_1
b. roll_no
c. $1234
d. All of the above

Answer: d. All of the above



4. Which of the following are Java keywords?

a. return
b. void
c. private
d. Both b and c

Answer: d. Both b and c


5. Can a byte type data be assigned to int type in Java?

a. True
b. False

Answer: a. True


6. Which of the following is a keyword in Java?

a. implement
b. friend
c. synchronized
d. NULL

Answer: c. synchronized


7. Which of the following are not legal identifiers?

a. 1name
b. stud+num
c. room_num
d. both a and b  

Answer: d. both a and b


8. Which of the following statements is false about objects?

a. An object is an instance of a class
b. Objects do not allow encapsulation  
c. An Object can access both static and instance data
d. All of the above

Answer: b. Objects do not allow encapsulation


9. Name the Collection interface implemented by the class Hashtable.

a. List
b. Set
c. Map  
d. SortedSet

Answer: c. Map


10. Name the Collection interface implemented by the TreeMap class

a. Set
b. SortedSet
c. Tree
d. SortedMap

Answer: d. SortedMap