Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of these classes can schedule task for execution in future?(a) Thread(b) Timer(c) System(d) ObserverI got this question in final exam.This interesting question is from Observable & Timer Class topic in division java.util – More Utility Classes of Java

Answer»

The CORRECT choice is (b) Timer

To explain I would say: Timer and TimerTask are the classes that support the ability to SCHEDULE tasks for EXECUTION at some future TIME.

2.

Which of these interfaces is implemented by TimerTask class?(a) Runnable(b) Thread(c) Observer(d) ThreadCountI got this question by my college director while I was bunking the class.This interesting question is from Observable & Timer Class in section java.util – More Utility Classes of Java

Answer»

The CORRECT ANSWER is (a) Runnable

Explanation: NONE.

3.

Which of these methods is called when observed object has changed?(a) setChanged()(b) update()(c) notifyObserver()(d) all of the mentionedThis question was addressed to me by my school principal while I was bunking the class.I'd like to ask this question from Observable & Timer Class in chapter java.util – More Utility Classes of Java

Answer» RIGHT OPTION is (d) all of the mentioned

Easy EXPLANATION: NONE.
4.

Which of these methods is used to notify observer the change in observed object?(a) update()(b) notify()(c) check()(d) observed()I had been asked this question in a national level competition.Query is from Observable & Timer Class in portion java.util – More Utility Classes of Java

Answer»

Right CHOICE is (a) update()

The BEST explanation: NONE.

5.

Which of these method of Locale class can be used to obtain country of operation?(a) getCountry()(b) whichCountry()(c) DisplayCountry()(d) getDisplayCountry()The question was asked in an interview for internship.The question is from Locale & Random Classes topic in chapter java.util – More Utility Classes of Java

Answer» RIGHT CHOICE is (d) getDisplayCountry()

The BEST I can EXPLAIN: NONE.
6.

Which of these methods calls update() method?(a) notify()(b) observeObject()(c) updateObserver()(d) notifyObserver()This question was addressed to me in an interview.I need to ask this question from Observable & Timer Class in portion java.util – More Utility Classes of Java

Answer»

The correct answer is (d) notifyObserver()

For EXPLANATION: notifyObserver() NOTIFIES all the OBSERVERS of the invoking OBJECT that it has changed by calling update(). A NULL is passed as the second argument to update().

7.

What is the use of Observable class?(a) It is used to create global subclasses(b) It is used to create classes that other part of the program can observe(c) It is used to create classes that can be accessed by other parts of program(d) It is used to create methods that can be accessed by other parts of programThe question was asked by my college director while I was bunking the class.I need to ask this question from Observable & Timer Class topic in portion java.util – More Utility Classes of Java

Answer»

Right answer is (B) It is used to CREATE CLASSES that other part of the program can observe

Explanation: The OBSERVABLE CLASS is used to create subclasses that other part of program can observe.

8.

Which of these class can generate pseudorandom numbers?(a) Locale(b) Rand(c) Random(d) None of the mentionedI had been asked this question during an interview.I would like to ask this question from Locale & Random Classes topic in chapter java.util – More Utility Classes of Java

Answer» CORRECT CHOICE is (C) Random

Best EXPLANATION: NONE.
9.

How many bits are used for generating random numbers?(a) 32(b) 64(c) 48(d) 8The question was posed to me in semester exam.My doubt is from Random Number topic in division java.util – More Utility Classes of Java

Answer» RIGHT answer is (c) 48

Easy explanation: RANDOM NUMBER can accept 64 bits but it only uses 48 bits for GENERATING random numbers.
10.

Which of these class produce objects with respect to geographical locations?(a) TimeZone(b) Locale(c) Date(d) SimpleTimeZoneThis question was posed to me during an online interview.My query is from Locale & Random Classes in section java.util – More Utility Classes of Java

Answer»

The correct choice is (B) LOCALE

To elaborate: The Locale CLASS isinstantiated to PRODUCE objects that each describe a GEOGRAPHICAL or cultural region.

11.

Which of these methods is not a Locale class?(a) UK(b) US(c) INDIA(d) KOREAI had been asked this question in an interview for internship.Origin of the question is Locale & Random Classes topic in division java.util – More Utility Classes of Java

Answer»

Correct choice is (C) INDIA

For explanation: INDIA is not a Locale CLASS.

12.

Math.random() guarantees uniqueness?(a) True(b) FalseThis question was posed to me in quiz.Enquiry is from Random Number topic in section java.util – More Utility Classes of Java

Answer»

The CORRECT answer is (b) False

The explanation: Math.random() doesn’t guarantee UNIQUENESS. To guarantee uniqueness we must store the generated value in the DATABASE and COMPARE against already generated values.

13.

What is the range of numbers returned by Math.random() method?(a) -1.0 to 1.0(b) -1 to 1(c) 0 to 100(d) 0.0 to 1.0I have been asked this question in semester exam.The question is from Random Number topic in section java.util – More Utility Classes of Java

Answer»

Right option is (d) 0.0 to 1.0

Explanation: Math.random() returns only DOUBLE VALUE greater than or EQUAL to 0.0 and LESS than 1.0.

14.

Which method is used to generate boolean random values in java?(a) nextBoolean()(b) randomBoolean()(c) previousBoolean()(d) generateBoolean()This question was posed to me in an interview for job.My question is taken from Random Number in chapter java.util – More Utility Classes of Java

Answer»

The correct OPTION is (a) nextBoolean()

For explanation I WOULD say: nextBoolean() method of java.util.Random CLASS is USED to GENERATE random numbers.

15.

Random is a final class?(a) True(b) FalseI got this question by my college professor while I was bunking the class.My doubt stems from Random Number in chapter java.util – More Utility Classes of Java

Answer»

Correct option is (b) False

For explanation: RANDOM is not a FINAL class and can be extended to implement the ALGORITHM as PER requirement.

16.

What is the return type of Math.random() method?(a) Integer(b) Double(c) String(d) BooleanThis question was posed to me in an online quiz.I'm obligated to ask this question of Random Number in chapter java.util – More Utility Classes of Java

Answer» CORRECT OPTION is (B) Double

For explanation: Math.random() method RETURNS floating point number or precisely a double.
17.

Which class is used to generate random number?(a) java.lang.Object(b) java.util.randomNumber(c) java.util.Random(d) java.util.ObjectI had been asked this question in an online interview.The above asked question is from Random Number in portion java.util – More Utility Classes of Java

Answer»

Correct option is (c) JAVA.util.Random

For explanation I WOULD say: java.util.random class is USED to generate random NUMBERS in java PROGRAM.