Posts

Computer Science Exam MCQs - Part 2

11. Which of the following data structures allows elements to be accessed in Last In, First Out (LIFO) order?    a) Queue    b) Stack    c) Linked List    d) Tree 12. Which programming language is widely used for developing web-based applications and is known for its simplicity and readability?    a) Java    b) C++    c) Python    d) Ruby 13. Which of the following sorting algorithms has the worst-case time complexity of O(n^2)?    a) Quick Sort    b) Merge Sort    c) Bubble Sort    d) Insertion Sort 14. In object-oriented programming, what is the process of creating a new instance of a class called?    a) Inheritance    b) Encapsulation    c) Polymorphism    d) Instantiation 15. Which of the following is NOT a fundamental data type in most programming languages?    a) Integer    b) Float    c) Strin...

Computer Science Exam MCQs - Part 1

1. CD, DVD, and floppy disk are all examples of; a- storage media b- input devices c- output devices d- both b and c e- none of the above 2. Typically the size of a compact disk (CD) in diameter is about; a- 2.6 inches b- 3.2 inches c- 3.8 inches d-  4.7 inches e-  5.3 inches 3. How many concurrent users approximately  can a server handle? a- 250 b- 400 c- 450 d- 500 e- depends on several factors 4. The storage capacity of a compact disk (CD) is about; a- 500 MB b- 700 MB c- 1000 MB d- 1 GB e- 1.5 GB 5. What is the maximum storage capacity of a floppy disk? a- 80 kilobytes b-  144 kilobytes c-  500 kilobytes d- 1.44 megabytes e- 7  megabytes 6. Microsoft Corporation developed the Disk Operating System (DOS) for the IBM Personal Computer in; a- 1981 b- 1975 c- 1985 d- 1991 e- 1995 7. Which of the following area performs hazardous tasks with the help of computerized robotic arms? a- ICU in hospitals  b- film s...

The arguments object in JavaScript

The arguments object in JavaScript is a function-specific local variable that provides access to the arguments passed to that function when it was called. However, it's important to note that the arguments object has some limitations and is generally considered less preferred in modern JavaScript for several reasons. Here's a breakdown of the arguments object: Availability: The arguments object is available within all non-arrow functions. Arrow functions do not have a built-in arguments object. Properties: The arguments object is array-like , meaning it has a length property (indicating the number of arguments passed) and allows indexing using numerical positions (similar to arrays). However, it does not have the full functionality of a true array and cannot be used with standard array methods like map or forEach. Limitations: Not a real array: As mentioned, the arguments object lacks the methods and behavior of a true array. Live collection: The arguments object is a live co...

Common Array methods in JavaScript that modify the array in place

The following are the common array methods in JavaScript that modify the original array instead of returning a new one: 1. pop():  Removes and returns the last element from an array. Example: myArray.pop(); 2. push():  Adds one or more elements to the end of an array and returns the new length of the array. Example: myArray.push(element1, element2); 3. shift():  Removes and returns the first element from an array. Example: myArray.shift(); 4. unshift():   Adds one or more elements to the beginning of an array and returns the new length of the array. Example: myArray.unshift(element1, element2); 5. splice():  This is a versatile method that can be used to: Remove elements from an array (splice(start, deleteCount)) Add elements to an array (splice(start, 0, element1, element2)) Replace elements in an array (splice(start, deleteCount, element1, element2)) Example: myArray.splice(2, 1); // Removes one element at index 2 myArray.splice(1, 0, 'newElement'); // Adds 'n...

What is the difference between iostream and iostream.h in cpp?

In C++, there are two seemingly similar headers for input/output operations: iostream and iostream.h. However, they have key differences you should be aware of: 1. Standard vs. Non-Standard: **iostream** is the standard header for input/output operations in C++. It is part of the C++ Standard Library and is guaranteed to be available and consistent across different compilers. **iostream.h** is a non-standard header . It was used in pre-standard C++ and some early compilers. It is not part of the C++ Standard Library and its availability and behavior might vary depending on the compiler. 2. Namespace: **iostream** defines everything within the **std** namespace. This helps avoid naming conflicts with other libraries or user-defined functions. **iostream.h** does not use namespaces. This means all its elements are directly available in the global namespace, which can lead to potential naming conflicts and is generally considered less modern practice. 3. Recommendations: Always use iostr...

Call by value vs Call by reference in c++

In C++, there are two main ways to pass arguments to functions: call by value and call by reference . Understanding the difference between them is crucial for writing effective and predictable code. Let's explore each method with examples: Call by Value: When you pass an argument by value, a copy of the value is passed to the function . Any changes made to the argument inside the function only affect the copy , not the original variable. Example: C++ void swap_values ( int x, int y) {   int temp = x;   x = y;   y = temp; } int main () {   int a = 5 , b = 10 ;   swap_values(a, b);   // After the function call, a will still be 5 and b will still be 10   std :: cout << "a: " << a << ", b: " << b << std :: endl ;   return 0 ; } Call by Reference: When you pass an argument by reference, the function receives the memory address of the original variable . Changes made to the argument inside the function directly...