Skip to main content

Modern Programming Languages MCQs with Answers

Practice important Modern Programming Languages MCQs with answers and explanations.

Multiple Choice Questions

Q581: Which of the following methods does not exist in the Thread class in Java?
  • A: start()
  • B: stop()
  • C: run()
  • D: sleep()
View Answer
B

Q582: In the Producer-Consumer example in Java, what is the role of the deposit() method?
  • A: It consumes items from the buffer.
  • B: It adds an item to the buffer.
  • C: It checks if the buffer is full.
  • D: It removes items from the buffer.
View Answer
B

Q583: Which of the following is a feature of Java compared to C++?
  • A: Java allows manual memory management.
  • B: Java supports automatic garbage collection.
  • C: Java does not support object-oriented programming.
  • D: Java lacks built-in exception handling.
View Answer
B

Q584: What is the purpose of the buffer in the Producer-Consumer example in Java?
  • A: It stores items that the producer creates and the consumer consumes.
  • B: It is used to pause threads.
  • C: It defines the number of threads in the program.
  • D: It manages the priority of threads.
View Answer
A

Q585: In the given example, which thread method is responsible for signaling other threads to wake up?
  • A: wait()
  • B: notify()
  • C: yield()
  • D: sleep()
View Answer
B

Q586: In Java threads, what is the function of the setPriority() method?
  • A: It sets the maximum time a thread can run.
  • B: It sets the priority of the thread.
  • C: It stops the thread after a certain time.
  • D: It checks if the thread is running.
View Answer
B

Q587: Which of the following statements about synchronization in Java is true?
  • A: Synchronization ensures that only one thread can access a shared resource at a time.
  • B: Synchronization allows multiple threads to access a shared resource at the same time.
  • C: Synchronization makes threads execute sequentially, even when resources are not shared.
  • D: Synchronization is used only to pause threads.
View Answer
A

Q588: In Java, which method is used to pause a thread until a specified condition is met?
  • A: wait()
  • B: notify()
  • C: sleep()
  • D: yield()
View Answer
A

Q589: What is the output of the following code? public class ThreadExample extends Thread { public void run() { for (int i = 1; i <= 100; i++) { System.out.println("Thread: " + i); } } }
  • A: Thread: 1 to Thread: 100
  • B: Thread: 1 only
  • C: No output
  • D: Exception occurs
View Answer
A

Q590: Which statement about Java thread methods is correct?
  • A: All thread methods can be called simultaneously.
  • B: Thread methods can be invoked to control the flow of execution.
  • C: Thread methods do not affect thread synchronization.
  • D: Thread methods cannot be overridden.
View Answer
B

Test Your Knowledge

Take a timed quiz on Modern Programming Languages

🚀 Start Quiz Now