Properties of Java Flashcards

1
Q

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

A

b) Variables must be assigned a specific type, which cannot change

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What feature of Java helps manage memory automatically?

a) Just-in-time compilation
b) Garbage collector
c) Built-in libraries
d) Statically typed system

A

b) Garbage collector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

c) It has built-in libraries for various tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

b) They all run on the Java Virtual Machine (JVM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

b) Ensures platform independence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

c) The compiler will produce an error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

b) It prevents bugs by ensuring operations are valid for the specified type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the following is an example of a dynamically typed language?

a) C
b) Java
c) Python
d) C++

A

c) Python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which term is often used to describe dynamically typed languages?

a) Strongly typed
b) Statically typed
c) Weakly typed
d) Just-in-time typed

A

c) Weakly typed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

b) Translates Java source code into bytecode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

c) Java compiles the entire program before execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

b) Translates bytecode into machine instructions while the program is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

c) It allows old programs to exploit advances in hardware and OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

c) It allows bytecode to be translated into machine code only when necessary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly