T TestsWorld

Free practice test · Sun

Java Exam

14 questions with a timer and instant results. Practise in short drills or take the full test, then see exactly which topics need work.

📝 14 questions ⏱ 20 min for all 🎯 Pass mark 70% 💸 Free, unlimited attempts
⚡
Short drills

Pick 10, 25 or 50 questions for a quick round, or take all of them.

💡
Learn as you go

Practice mode shows the right answer and an explanation for every question.

📊
See your weak spots

Your result shows strong and weak topics and what to read next.

What's in the test

Easy 29% Medium 50% Hard 21%
Javah Tool 1Vector Class 1Set Collection 1Vector Capacity 1Java Keywords 1Primitive Data Types 1File I/O 1Java Runtime Options 1Final Classes 1AWT Event Handling 1GridBagConstraints 1Collection Interface 1

Sample questions with answers

4 of the 14 questions in Java Exam. Try each one, then open the answer.

  1. Question 1
    Predict the output for the following command. javah –jni
    • A. Creates header file for use in Java Native Interface.
    • B. Prints out the status as it creates the header or stub file
    • C. Specifies the classpath for use with javah
    • D. None of the above
    Show answer
    Answer: A. Creates header file for use in Java Native Interface.
    It Creates header file for use in Java Native Interface. So the option 1 is the correct answer.
  2. Question 2
    Which of the following member functions of the Vector class allow you to add or insert a new element?
    • A. addElement()
    • B. AddElement()
    • C. insert()
    • D. addItem()
    Show answer
    Answer: A. addElement()
    addElement() is used for add a new element.member functions of the Vector class allow you to add or insert a new element through addElement().
  3. Question 3
    How does the Set collection object deal with duplicate elements?
    • A. The add method returns false if you try to add duplicate
    • B. An exception is thrown if a duplicate element is added to the collection
    • C. Compilation error
    • D. None of the above
    Show answer
    Answer: A. The add method returns false if you try to add duplicate
    The add method returns false if you try to add duplicate. Because add method is used for adding the new dara there is no any duplication on it.
  4. Question 4
    What is the effect of adding the sixth element to a vector created in the following manner:new Vector(5, 10);
    • A. The vector grows to a capacity of 5 elements
    • B. The vector grows to a capacity of 10 elements
    • C. The vector grows to a capacity of 15 elements
    • D. You cannot change the initial capacity
    Show answer
    Answer: C. The vector grows to a capacity of 15 elements
    The vector grows to a capacity of 10 elements. When we added the 6th element on that then the capacity becomes 10

Want all 14 with a timer and a topic-wise result? Start the free test at the top of this page.

About this practice test

This test is for proving your skills in Java. The course for the test covers the basic topics of Java like: <ul><li> Basic Syntax <li>Standard Library <li>Exception Handling <li>Event Handling <li>Streams and File Handling <li>Layouts and Calendars <li>JDK Overview</li></ul>

This practice test belongs to TestsWorld's Sun Microsystems certification track (now Oracle-administered). The bank covers historical SCJP, SCJD, SCWCD, SCEA and SCSA / SCNA exams across Java, Solaris and Sun system administration. These exams are largely retired but the question banks remain useful as language-fundamentals practice and for legacy-system support.

What this practice test gives you

15 multiple-choice questions covering the subject area, served from a randomised order so each attempt feels fresh. Take the test at your own pace. Allowed time per attempt: 20 min. Pass mark: 70%.

Study tips. Read every explanation, including on questions you answered correctly — they often surface adjacent concepts you may face on the live exam. After a full attempt, review your incorrect and skipped questions in detail before re-attempting. Combined with official study material, this practice bank is most effective when you cycle through it multiple times over a few weeks of preparation.

Before you start: device, fullscreen and proctoring