Oop Theory Test
Oop Theory Test
Oop Theory Test
**a) Exceptions**
- **Definition:** An exception is an unexpected condition or error that arises during program execution.
It disrupts the normal flow of control, allowing the program to handle the error gracefully and
potentially recover or terminate execution.
- **Examples in C:**
1. **Division by zero:** Attempting to divide a number by zero results in an exception. You can use
exception handling mechanisms (like `try-catch` blocks) to trap this error and provide a meaningful error
message or take corrective actions.
2. **File access errors:** When trying to open a non-existent file or perform an unauthorized
operation on a file (e.g., writing to a read-only file), an exception might occur. Exception handling helps
you address these issues and provide informative feedback to the user.
- **UI (User Interface):** The visual components and interactive elements users directly interact with in
a digital product (e.g., screens, buttons, menus, icons, fonts, color schemes). UI design focuses on
making these elements aesthetically pleasing, intuitive, and easy to use.
- **UX (User Experience):** The overall experience a user has when interacting with a product. It
encompasses the entire interaction journey, including usability, usefulness, accessibility, efficiency,
emotions, and brand perception. UI is a crucial aspect of UX, but UX goes beyond visuals to consider the
user's needs, goals, and overall satisfaction.
**c) Responsive Design vs. Adaptive Design**
In the context of GUI (Graphical User Interface) applications, responsive design and adaptive design
address how interfaces adapt to different screen sizes and devices:
- **Responsive Design:** Employs a flexible and fluid layout that automatically adjusts to fit the
dimensions of the user's device (desktop, tablet, mobile phone). Responsive layouts use CSS media
queries to apply different styles based on screen size and resolution. This creates a seamless user
experience across devices.
- **Adaptive Design:** Presents multiple, pre-designed layouts specifically optimized for different
device categories. The application detects the user's device and delivers the most suitable layout. While
adaptive design caters well to a limited set of devices, it might not be as flexible for continuously
evolving screen sizes and resolutions.
- **Improved code readability and maintainability:** Dividing code into smaller, focused functions
makes the code easier to understand, modify, and debug.
- **Reduced redundancy:** Common code can be encapsulated in functions, preventing duplicate code
and promoting consistency.
- **Enhanced reusability:** Functions can be reused throughout the program or even in other
programs, promoting code efficiency and modularity.
- **Better organization:** Functions group related operations together, promoting a logical code
structure.
- **Easier testing:** Smaller, focused functions are easier to test and isolate potential bugs.
**e) Built-in Functions vs. User-defined Functions**
- **Built-in Functions (Framework Functions):** Predefined functions provided by the .NET Framework
or C# libraries. These functions perform common tasks like input/output (I/O) operations, string
manipulation, mathematical calculations, and more. You can directly call them in your code without
needing to write the implementation yourself.
- **User-defined Functions:** Functions that you create yourself to encapsulate specific functionality
within your program. You define the function's name, parameters, and the logic it executes.
- **Example:**
```csharp
```
These data structures differ in how they store and access data:
- **Structures:**
- User-defined types that group related variables of different data types under a single name.
- Stores a collection of variables that are accessed using dot notation (`.`) with the structure's name and
variable name (e.g., `point.X`, `point.Y`).
- Each structure instance holds its own copy of the data.
- **Arrays:**
- A collection of elements of the same data type, accessed using an index (starting from 0).
- Changes made to one element in an array affect all other elements of the same type within the