Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 30
Q581:
Which of the following methods does not exist in the Thread class in Java?
A. start()
B. stop()
C. run()
D. sleep()
Correct Answer:
B
Chapter: 30
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.
Correct Answer:
B
Chapter: 30
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.
Correct Answer:
B
Chapter: 30
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.
Correct Answer:
A
Chapter: 30
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()
Correct Answer:
B
Chapter: 30
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.
Correct Answer:
B
Chapter: 30
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.
Correct Answer:
A
Chapter: 30
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()
Correct Answer:
A
Chapter: 30
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
Correct Answer:
A
Chapter: 30
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.
Correct Answer:
B
Chapter: 30
Q591:
Which statement about exception handling in Java is true?
A. Exceptions in the catch block are never handled.
B. Exception handling prevents all exceptions from being thrown.
C. Exceptions in the finally block are not handled.
D. Exception handling allows for graceful error recovery.
Correct Answer:
D
Chapter: 30
Q592:
What happens when an uncaught exception occurs in a try block with a catch clause in Java?
A. The catch block executes, then the finally block executes, then the statement following the try block.
B. The catch block executes, then the statement following the try block.
C. The finally block executes, then the statement following the try block.
D. The catch block is skipped.
Correct Answer:
A
Chapter: 31
Q593:
When was C# released by Microsoft?
A. 1999
B. 2000
C. 2001
D. 2002
Correct Answer:
B
Chapter: 31
Q594:
C# is a _______ language.
A. weakly-typed
B. strongly-typed
C. loosely-typed
D. untyped
Correct Answer:
B
Chapter: 31
Q595:
What platform is C# part of?
A. .NET framework
B. Java framework
C. Python framework
D. Ruby framework
Correct Answer:
A
Chapter: 31
Q596:
What is the abbreviation for the Common Language Runtime in C#?
A. CLR
B. JVM
C. JRE
D. VMM
Correct Answer:
A
Chapter: 31
Q597:
In C#, which operator is used for member access?
A. ->
B. .
C. ::
D. =>
Correct Answer:
B
Chapter: 31
Q598:
C# is similar to which programming languages?
A. Java and Python
B. Java and C++
C. Java and Ruby
D. Java and JavaScript
Correct Answer:
B
Chapter: 31
Q599:
Which language uses Microsoft Intermediate Language (MSIL)?
A. Java
B. C#
C. Python
D. Ruby
Correct Answer:
B
Chapter: 31
Q600:
What is the term for C#'s automatic memory management feature?
A. Garbage Collection
B. Memory Leak Prevention
C. Manual Memory Allocation
D. Heap Management
Correct Answer:
A