Java's Class Library and Garbage Collector Flashcards
What is the Java Class Library (JCL)?
a) A collection of Java Virtual Machines
b) A set of common libraries that developers must download separately
c) A collection of commonly used programming resources and packages
d) A group of Java applications for advanced users
c) A collection of commonly used programming resources and packages
Which Java package contains basic classes and interfaces such as the Object class and the Thread class?
a) java.sql
b) java.math
c) java.lang
d) java.util
c) java.lang
What can the java.math package be used for?
a) Managing SQL database connections
b) Performing basic math operations such as logarithms and trigonometry
c) Formatting text and dates
d) Creating multi-threaded programs
b) Performing basic math operations such as logarithms and trigonometry
Which Java package would you use to format text and dates?
a) java.sql
b) java.math
c) java.lang
d) java.text
d) java.text
What is the primary purpose of Java’s garbage collector?
a) To allocate new resources for all variables
b) To automatically clean up unused objects and free up resources
c) To optimize the performance of mathematical calculations
d) To interpret bytecode into machine code
b) To automatically clean up unused objects and free up resources
What is considered an unused object in the context of Java’s garbage collector?
a) An object that is still being referenced by the program
b) An object that has not been created yet
c) An object no longer referenced by any part of the running program
d) An object that is allocated but never initialized
c) An object no longer referenced by any part of the running program
What does Java’s garbage collector do when it identifies unreferenced objects?
a) It reallocates them for future use
b) It deletes them and frees up resources like memory and processor time
c) It stores them in a temporary buffer
d) It compresses them to save space
b) It deletes them and frees up resources like memory and processor time
Which language feature makes garbage collection unnecessary in Java?
a) Explicit resource allocation and deallocation by the developer
b) Use of the malloc and free functions
c) Built-in garbage collector that runs automatically
d) Manual memory management
c) Built-in garbage collector that runs automatically
Which of the following is a downside of Java’s automatic garbage collector?
a) It cannot identify unused objects
b) It requires the developer to free memory explicitly
c) It adds some additional overhead by consuming resources itself
d) It only works for dynamic programming languages
c) It adds some additional overhead by consuming resources itself
What are JVM languages?
a) Languages that run only on Java Virtual Machines with no compilation
b) Languages with interpreters that translate directly to machine code
c) Languages that can be compiled into JVM bytecode and run on a JVM
d) Languages that are incompatible with Java syntax
c) Languages that can be compiled into JVM bytecode and run on a JVM
Which of the following JVM languages is primarily used for Android app development?
a) Groovy
b) Scala
c) Clojure
d) Kotlin
d) Kotlin
Which JVM language is closely related to the Lisp programming language?
a) Scala
b) Kotlin
c) Groovy
d) Clojure
d) Clojure
What makes learning JVM languages easier for Java developers?
a) All JVM languages use a completely different syntax from Java
b) JVM languages have similar syntax and structure to Java
c) Java developers must learn JVM languages from scratch
d) JVM languages do not run on the Java Virtual Machine
b) JVM languages have similar syntax and structure to Java