COSC 1P02 Exam Questions with
Verified Solutions
What is a variable in programming?
A variable in programming is a named storage location in memory that holds a value, which
can be changed during program execution.
What are the common data types used in programming?
Common data types us...
COSC 1P02 Exam Questions with
Verified Solutions
What is a variable in programming?
✔✔A variable in programming is a named storage location in memory that holds a value, which
can be changed during program execution.
What are the common data types used in programming?
✔✔Common data types used in programming include integers, floating-point numbers,
characters, strings, and booleans.
What is the purpose of a control structure in programming?
✔✔The purpose of a control structure is to dictate the flow of execution in a program, allowing
for decision-making and repeated actions based on certain conditions.
What is the difference between a function and a procedure?
✔✔A function is a block of code that performs a specific task and returns a value, while a
procedure (or subroutine) performs a task but does not return a value.
1
,What is an algorithm?
✔✔An algorithm is a step-by-step procedure or formula for solving a problem or completing a
task, typically expressed in a structured way.
How do you perform error handling in programming?
✔✔Error handling in programming involves anticipating and managing potential errors using
techniques like try-catch blocks, exception handling, and validation checks.
What is a loop, and why is it used?
✔✔A loop is a control structure that allows for repeated execution of a block of code as long as a
specified condition is true, helping to automate repetitive tasks.
What are arrays, and how are they used in programming?
✔✔Arrays are data structures that store multiple values of the same type in a single variable,
allowing for efficient access and manipulation of collections of data.
What is the significance of comments in code?
✔✔Comments are used to annotate code, providing explanations or notes for developers, which
improves code readability and maintainability.
2
, What is the concept of scope in programming?
✔✔Scope refers to the visibility or lifetime of a variable within a program, determining where a
variable can be accessed or modified.
What is recursion, and how does it work?
✔✔Recursion is a programming technique where a function calls itself to solve smaller instances
of the same problem, with a base case to terminate the recursive calls.
What is the difference between a stack and a queue?
✔✔A stack is a data structure that follows the Last In, First Out (LIFO) principle, while a queue
follows the First In, First Out (FIFO) principle.
What is object-oriented programming (OOP)?
✔✔Object-oriented programming (OOP) is a programming paradigm that uses objects to
represent data and methods to manipulate that data, focusing on concepts like encapsulation,
inheritance, and polymorphism.
How can you improve the performance of your code?
3
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller StellarScores. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.99. You're not tied to anything after your purchase.