CCP Programming Concepts & Application Development 2 — Questions and Answers
Question 1: Which design pattern ensures a class has only one instance and provides a global point of access to it?
- Factory
- Singleton (Correct answer)
- Observer
- Decorator
Correct answer: Singleton
The Singleton pattern restricts instantiation of a class to one object and provides a global access point.
Question 2: In object-oriented programming, what term describes a subclass providing a specific implementation of a method already defined in its parent class?
- Overloading
- Encapsulation
- Overriding (Correct answer)
- Abstraction
Correct answer: Overriding
Method overriding allows a subclass to provide its own implementation of a method inherited from a superclass.
Question 3: What is the time complexity of binary search on a sorted array of n elements?
- O(n)
- O(n²)
- O(log n) (Correct answer)
- O(n log n)
Correct answer: O(log n)
Binary search repeatedly halves the search space, resulting in O(log n) time complexity.
Question 4: Which software development methodology emphasizes iterative development, customer collaboration, and responding to change?
- Waterfall
- Agile (Correct answer)
- PRINCE2
- CMMI
Correct answer: Agile
Agile methodology prioritizes iterative delivery, continuous feedback, and flexibility over rigid upfront planning.
Question 5: In a relational database context, what does ACID stand for?
- Atomicity, Consistency, Isolation, Durability (Correct answer)
- Access, Control, Integrity, Distribution
- Atomicity, Concurrency, Isolation, Distribution
- Access, Consistency, Integration, Durability
Correct answer: Atomicity, Consistency, Isolation, Durability
ACID stands for Atomicity, Consistency, Isolation, and Durability — the four properties that guarantee reliable database transactions.
Question 6: What is a 'race condition' in concurrent programming?
- A performance benchmark where two algorithms compete
- A bug where program behavior depends on unpredictable timing of multiple threads (Correct answer)
- A scheduling algorithm that prioritizes faster processes
- A design pattern for parallel processing
Correct answer: A bug where program behavior depends on unpredictable timing of multiple threads
A race condition occurs when a program's outcome depends on the relative timing of concurrent threads or processes accessing shared resources.
Question 7: Which of the following best describes 'polymorphism' in object-oriented programming?
- The ability to hide internal implementation details
- The ability of different objects to respond to the same interface in different ways (Correct answer)
- The process of creating objects from classes
- The inheritance of attributes from a parent class
Correct answer: The ability of different objects to respond to the same interface in different ways
Polymorphism allows objects of different types to be treated through a common interface, each responding according to its own type.
Which design pattern ensures a class has only one instance and provides a global point of access to it?