Java interview questions part 8

Java interview questions part 8

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. What is the use of Observable class?

Correct Answer is : It is used to create classes that other part of the program can observe

2. Which of these methods is used to notify observer the change in observed object?

Correct Answer is : update()

3. Which of these methods calls update() method?

Correct Answer is : notifyObserver()

4. Which of these methods is called when observed object has changed?

Correct Answer is : all of the mentioned

5. Which of these classes can schedule task for execution in future?

Correct Answer is : Timer

6. Which of these interfaces is implemented by TimerTask class?

Correct Answer is : Runnable

7. Which of these package provides the ability to read and write in Zip format?

Correct Answer is : java.util.zip

8. Random is a final class?

Correct Answer is : FALSE

9. How many bits are used for generating random numbers?

Correct Answer is : 48

10. Math.random() guarantees uniqueness?

Correct Answer is : FALSE

11. Which class is used to generate random number?

Correct Answer is : java.util.Random

12. Which method is used to generate boolean random values in java?

Correct Answer is : nextBoolean()

13. What is the return type of Math.random() method?

Correct Answer is : Double

14. What is the range of numbers returned by Math.random() method?

Correct Answer is : 0.0 to 1.0

15. What would be the output of following code snippet? int a = random.nextInt(15) + 1;

Correct Answer is : Random number between 1 to 15, including 1 and 15

16. What would be the output of following code snippet? int a = random.nextInt(7) + 4;

Correct Answer is : Random number between 4 to 10, including 4 and 10

17. What is the signature of Math.random() method?

Correct Answer is : public static double random()

18. Which of these packages contains all the event handling interfaces?

Correct Answer is : java.awt.event

19. Which of these interfaces handles the event when a component is added to a container?

Correct Answer is : ContainerListener

20. Which of these interfaces define a method actionPerformed()?

Correct Answer is : ActionListener

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon