Study Guide Questions and Answers
Rated A+
What will happen if you divide a double by zero?
✔✔ It returns Infinity
How do you print text in Java?
✔✔ Using System.out.println()
What symbol is used to denote a single-line comment in Java?
✔✔ //
What is the result of dividing an integer by zero in Java?
✔✔ ArithmeticException
What keyword is used to create an object in Java?
✔✔ new
1
,How do you declare a constant variable in Java?
✔✔ Using the final keyword
Which data type is used to store decimal numbers in Java?
✔✔ float or double
What is the purpose of the break statement in Java?
✔✔ To exit a loop or switch statement
What is the difference between == and equals()?
✔✔ == compares memory locations, equals() compares content
How do you convert a string to lowercase?
✔✔ Using toLowerCase()
Which operator is used for bitwise AND?
✔✔ &
2
, What is method overriding?
✔✔ Redefining a method in a subclass that exists in the parent class
What will "hello world".replace("world", "Java") return?
✔✔ hello Java
What does the default keyword do in a switch statement?
✔✔ Specifies the code to run if no case matches
How do you check if an ArrayList is empty?
✔✔ Using isEmpty()
What is the difference between List and Set?
✔✔ List allows duplicates, Set does not
How do you generate a random integer in Java?
✔✔ Using Random.nextInt() or Math.random()
3