Java Assertions Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of the java.lang package and its commonly used classes, including Object, String, StringBuilder, Math, System, Wrapper classes, and the Runtime class.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. java.lang
The java.lang package is automatically imported by the Java compiler, so its commonly used classes can be referenced without an explicit import statement.
A. Object
java.lang.Object is the superclass of all Java classes, either directly or indirectly.
A. toString()
The Object class provides toString(), which can be overridden to return a meaningful textual representation of an object.
A. String
String objects are immutable, meaning their contents cannot be changed after the object is created.
A. StringBuilder
StringBuilder provides a mutable sequence of characters and is useful when repeated string modifications are needed.
A. Math
The java.lang.Math class provides static methods for common mathematical operations.
A. System
The java.lang.System class provides fields such as System.in, System.out, and System.err.
A. Integer
Integer is the wrapper class corresponding to the primitive int type.
A. Integer.parseInt()
Integer.parseInt() parses a String argument and returns its value as a primitive int.
A. Character
The Character class wraps a value of the primitive char type and provides useful character-related methods.
A. Number
java.lang.Number is the abstract superclass for several numeric wrapper classes, including Integer, Double, and Float.
A. Runtime
The java.lang.Runtime class provides access to information and functionality related to the Java runtime environment.
A. currentTimeMillis()
System.currentTimeMillis() returns the current time in milliseconds since the Unix epoch.
A. Wrapper classes
Wrapper classes such as Boolean, Byte, Short, and Long provide parsing methods for converting String values into corresponding primitive values.
A. equals()
The Object class defines equals(), which can be overridden by classes to provide logical equality comparison.