Unit3 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

UNIT-3

1. What is a primary purpose of subprograms in programming languages?


a) To improve program readability
b) To modularize code and promote reusability
c) To increase program execution speed
d) To minimize memory usage
2. Which of the following is not a design issue for subprograms?
a) Parameter passing methods b) Overloading subprograms
c) Local referencing environments d) Memory allocation techniques
3. What is a local referencing environment?
a) It defines the scope and visibility of variables within a subprogram
b) It refers to the process of calling subprograms indirectly
c) It determines the method of parameter passing
d) It specifies the execution sequence of subprograms
4. Which parameter passing method passes the actual parameter to the subprogram?
a) Pass-by-value b) Pass-by-reference
c) Pass-by-result d) Pass-by-name
5. What are closures in programming languages?
a) Subprograms that can be called indirectly
b) Parameterized abstract data types
c) User-defined overloaded operators
d) Nested subprograms with access to the enclosing scope's variables
6. What is the concept of abstraction in abstract data types (ADTs)?
a) Hiding implementation details and providing only essential information
b) Exposing all implementation details for flexibility
c) Making data structures accessible to any part of the program
d) Minimizing the usage of memory in data structures
7. Which encapsulation construct provides a way to define both data and the functions
that operate on the data?
a) Abstract data types b) Overloaded subprograms
c) Coroutines d) Closures
8. What is a parameterized abstract data type?
a) An ADT that accepts parameters to customize its behavior
b) An ADT that only operates on predefined parameters
c) An ADT that doesn't accept any parameters
d) An ADT that operates on subprograms
9. Which design issue refers to the naming conventions and visibility of encapsulations?
a) Parameterized ADT b) Encapsulation constructs
c) Naming encapsulations d) Design issues for functions
10. What is the primary benefit of using coroutines?
a) To improve program readability b) To minimize memory usage
c) To enable cooperative multitasking d) To modularize code and promote reusability
FILL IN THE BLANKS
1. _____________ defines the scope and visibility of variables within a subprogram.
2. Pass-by-_________ parameter passing method passes the address of the actual
parameter.
3. _____________ are nested subprograms with access to the enclosing scope's variables.
4. _____________ ADT accepts parameters to customize its behavior.
5. Encapsulation constructs provide a way to define both data and the ___________ that
operate on the data.
6. Coroutines enable ___________ multitasking.
7. Design issues for subprograms include parameter passing methods and ___________
subprograms.
8. ___________ is the primary purpose of subprograms in programming languages.
9. The concept of abstraction involves hiding implementation details and providing
only ___________ information.
10. Naming encapsulations involves specifying the ___________ and visibility of
encapsulations.
UNIT-4
1. What is the primary purpose of using semaphores in concurrency?
a) To facilitate message passing b) To control access to shared resources
c) To define monitors d) To handle exceptions

2. Which concurrency mechanism allows for the orderly access to shared resources by
multiple processes or threads?
a) Monitors b) Message Passing
c) Java Threads d) Exception Handling
3. Which programming language provides support for concurrent programming
through the concept of Java Threads?
a) C++ b) Ada c) Java d) C#
4. What is the primary benefit of using monitors in concurrent programming?
a) Simplified exception handling b) Efficient message passing
c) Avoidance of race conditions d) Increased program execution speed
5. What does statement-level concurrency refer to?
a) Handling exceptions at the statement level
b) Executing multiple statements concurrently
c) Coordinating events in a program
d) Passing messages between threads

6. Exception handling in programming languages like Ada, C++, and Java allows
programs to:
a) Completely ignore errors during execution
b) Gracefully recover from errors and continue execution
c) Terminate execution immediately upon encountering an error
d) Increase the likelihood of encountering errors
7. Event handling in programming languages like Java and C# is primarily used for: a)
Managing exceptions during program execution b) Coordinating concurrent
processes c) Responding to user interactions and system events d) Controlling access
to shared resources
8. Subprogram-level concurrency primarily deals with:
a) Handling exceptions within subprograms
b) Coordinating multiple subprograms to execute concurrently
c) Passing messages between subprograms
d) Implementing monitors within subprograms

9. In message passing, communication between concurrent processes occurs through:


a) Shared memory b) Monitors
c) Semaphores d) Message queues
10. Concurrency in functional languages is primarily achieved through:
a) Java Threads b) Monitors c) Message Passing d) Statement-level concurrency
FILL IN THE BLANKS

1. ____________ is a synchronization construct used to control access to shared


resources in concurrent programming.
2. ____________ allows multiple processes or threads to share a common
resource with mutual exclusion.
3. ____________ is a mechanism for communication and synchronization
between concurrent processes or threads.
4. In ____________, concurrent execution is achieved through the use of
lightweight processes within the Java programming language.
5. ____________ refers to the ability of a program to handle unexpected
conditions or errors during execution.
6. ____________ provides a structured approach to handle errors in
programming languages like Ada, C++, and Java.
7. ____________ is a paradigm where programs respond to user interactions or
system events, often found in graphical user interfaces.
8. ____________ involves the coordination of multiple processes or threads to
execute concurrently within subprograms.
9. ____________ concurrency refers to the ability to execute multiple statements
simultaneously within a program.
10.____________ languages like Haskell and Erlang employ functional
programming concepts to achieve concurrent execution.

You might also like