Properties of Java Flashcards
What does it mean for Java to be statically typed?
a) Variables can change types at any time
b) Variables must be assigned a specific type, which cannot change
c) Variables do not require any type
d) Variables are only checked at runtime
b) Variables must be assigned a specific type, which cannot change
What feature of Java helps manage memory automatically?
a) Just-in-time compilation
b) Garbage collector
c) Built-in libraries
d) Statically typed system
b) Garbage collector
Which of the following is a property of Java that makes it easy to use?
a) It has a dynamic typing system
b) It is interpreted at runtime
c) It has built-in libraries for various tasks
d) It requires manual memory management
c) It has built-in libraries for various tasks
Which statement is true about Java’s relationship with other languages like Groovy and Scala?
a) They are unrelated and run on different platforms
b) They all run on the Java Virtual Machine (JVM)
c) They are interpreted directly by the operating system
d) They cannot use Java libraries
b) They all run on the Java Virtual Machine (JVM)
What does the Java Virtual Machine (JVM) primarily achieve for Java programs?
a) Allows them to run without a compiler
b) Ensures platform independence
c) Speeds up garbage collection
d) Enables manual memory management
b) Ensures platform independence
What happens if you declare a variable in Java without setting a type?
a) The program will run but may produce errors
b) The compiler will ignore the variable
c) The compiler will produce an error
d) The variable will default to an integer
c) The compiler will produce an error
What is one of the main advantages of static typing in Java?
a) It allows variables to change types dynamically
b) It prevents bugs by ensuring operations are valid for the specified type
c) It speeds up the compilation process
d) It allows more flexible programming
b) It prevents bugs by ensuring operations are valid for the specified type
Which of the following is an example of a dynamically typed language?
a) C
b) Java
c) Python
d) C++
c) Python
Which term is often used to describe dynamically typed languages?
a) Strongly typed
b) Statically typed
c) Weakly typed
d) Just-in-time typed
c) Weakly typed
What does the Java compiler do?
a) Translates bytecode into machine code
b) Translates Java source code into bytecode
c) Interprets Java source code directly
d) Executes Java programs in real-time
b) Translates Java source code into bytecode
What is the main difference between a compiled language like Java and an interpreted language like Python?
a) Java executes statements one at a time
b) Java is interpreted, while Python is compiled
c) Java compiles the entire program before execution
d) Python compiles the entire program before execution
c) Java compiles the entire program before execution
What does the just-in-time (JIT) compiler do in Java?
a) Compiles Java source code into bytecode ahead of time
b) Translates bytecode into machine instructions while the program is running
c) Converts machine instructions back into bytecode
d) Compiles Java programs entirely before execution
b) Translates bytecode into machine instructions while the program is running
Why is just-in-time compilation beneficial for older Java programs?
a) It allows old programs to be automatically updated
b) It enables older programs to run faster
c) It allows old programs to exploit advances in hardware and OS
d) It skips the need for bytecode translation
c) It allows old programs to exploit advances in hardware and OS
What is a key advantage of just-in-time compilation in Java?
a) It eliminates the need for a Java compiler
b) It improves the performance of Java programs by precompiling them
c) It allows bytecode to be translated into machine code only when necessary
d) It allows Java programs to be interpreted line by line
c) It allows bytecode to be translated into machine code only when necessary