Answers Latest Version Already Passed
Which of the following is a valid access modifier in Java?
A. open
B. final
C. private
D. internal
✔✔ C. private
Which data type can store decimal values in Java?
A. int
B. double
C. byte
D. char
✔✔ B. double
Which statement about Java arrays is true?
A. Arrays can be resized dynamically
1
,B. Arrays have a fixed size once initialized
C. Arrays are always passed by value
D. Arrays cannot store objects
✔✔ B. Arrays have a fixed size once initialized
Which of the following is used to handle exceptions in Java?
A. try-catch
B. finalize
C. break
D. repeat
✔✔ A. try-catch
Which loop structure exists in Java?
A. repeat-until
B. foreach
C. do-while
D. until
✔✔ C. do-while
2
,Which of the following is a wrapper class in Java?
A. int
B. Boolean
C. char
D. float
✔✔ B. Boolean
Which statement about the `static` keyword in Java is true?
A. A `static` method can access non-static instance variables directly
B. A `static` variable is shared among all instances of a class
C. A `static` block runs multiple times for each object created
D. A `static` method belongs to object instances
✔✔ B. A `static` variable is shared among all instances of a class
Which keyword is used to create a thread in Java?
A. extends Thread
B. extends Runnable
3
, C. extends Callable
D. extends Process
✔✔ A. extends Thread
Which of the following is a valid way to declare a `main` method in Java?
A. public void main(String[] args)
B. static public main(String args)
C. public static void main(String[] args)
D. main(String[] args)
✔✔ C. public static void main(String[] args)
Which statement about Java constructors is true?
A. A constructor must have the same name as the class
B. A constructor can return a value
C. A constructor must always be declared explicitly
D. A constructor cannot be overloaded
✔✔ A. A constructor must have the same name as the class
4