0% found this document useful (0 votes)
60 views10 pages

Previous Year Derived Questions

The document contains a section with multiple choice questions about programming concepts like data types, SQL statements, Python syntax and OOP concepts. Another section contains questions that require explanations or code snippets to demonstrate programming concepts.

Uploaded by

smathur_ind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views10 pages

Previous Year Derived Questions

The document contains a section with multiple choice questions about programming concepts like data types, SQL statements, Python syntax and OOP concepts. Another section contains questions that require explanations or code snippets to demonstrate programming concepts.

Uploaded by

smathur_ind
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Section A

1. What data type is used to store a sequence of text characters in Python?


 a) int
 b) float
 c) str
 d) list
 Correct Answer: c) str
2. Which SQL function is used to count the number of rows in a database table?
 a) SUM
 b) COUNT
 c) MAX
 d) AVG
 Correct Answer: b) COUNT
3. Which of the following is a valid IPv4 address?
 a) 192.300.1.1
 b) 192.168.1.1
 c) 256.168.1.1
 d) 192.168.1.256
 Correct Answer: b) 192.168.1.1
4. In Python, which of the following keywords is used for function definition?
 a) function
 b) def
 c) define
 d) func
 Correct Answer: b) def
5. Which command is used to delete records from a table in SQL?
 a) REMOVE
 b) DELETE
 c) DROP
 d) CLEAR
 Correct Answer: b) DELETE
6. What is the maximum value of an unsigned 8-bit binary number?
 a) 255
 b) 256
 c) 127
 d) 128
 Correct Answer: a) 255
7. In the context of OOP, what does encapsulation mean?
 a) Inheritance of methods
 b) Wrapping of data and methods into a single unit
 c) Overloading of methods
 d) Overriding of methods
 Correct Answer: b) Wrapping of data and methods into a single unit
8. Which protocol is used to send emails?
 a) FTP
 b) HTTP
 c) SMTP
 d) TCP
 Correct Answer: c) SMTP
9. What type of error will be raised if you try to access an index that is not in a list?
 a) SyntaxError
 b) IndexError
 c) KeyError
 d) TypeError
 Correct Answer: b) IndexError
10. Which of the following is a correct way to declare a dictionary in Python?
 a) my_dict = {1: "apple", 2: "banana"}
 b) my_dict = [1:"apple", 2:"banana"]
 c) my_dict = (1: "apple", 2: "banana")
 d) my_dict = <1:"apple", 2:"banana">
 Correct Answer: a) my_dict = {1: "apple", 2: "banana"}
11. In computer networks, what does LAN stand for?
 a) Large Access Network
 b) Local Area Network
 c) Long Area Network
 d) Low Area Network
 Correct Answer: b) Local Area Network
12. Which Python library is commonly used for scientific computing and data analysis?
 a) Django
 b) Flask
 c) Numpy
 d) Requests
 Correct Answer: c) Numpy
13. What does the 'HAVING' clause do in SQL?
 a) Specifies a search condition for a group or an aggregate
 b) Specifies a search condition for the columns retrieved
 c) Updates data in a database
 d) Deletes data from a database
 Correct Answer: a) Specifies a search condition for a group or an aggregate
14. What does CSS stand for in web development?
 a) Cascading Style Sheets
 b) Computer Style Sheets
 c) Creative Style Sheets
 d) Colorful Style Sheets
 Correct Answer: a) Cascading Style Sheets
15. Which of the following is NOT a Python data structure?
 a) List
 b) Dictionary
 c) Array
 d) Tuple
 Correct Answer: c) Array
16. Which of the following operations will correctly concatenate two lists in Python?
 a) [1, 2, 3] + [4, 5, 6]
 b) [1, 2, 3] .append([4, 5, 6])
 c) [1, 2, 3] .concat([4, 5, 6])
 d) [1, 2, 3] & [4, 5, 6]
 Correct Answer: a) [1, 2, 3] + [4, 5, 6]
17. In SQL, which keyword is used to sort the result-set?
 a) SORT
 b) ORDER BY
 c) ARRANGE
 d) ALIGN
 Correct Answer: b) ORDER BY
18. Which protocol ensures secure transmission of data over the internet?
 a) HTTP
 b) FTP
 c) HTTPS
 d) SMTP
 Correct Answer: c) HTTPS
19. What will be the output of the following Python code?
print(8 // 3)
 a) 2.67
 b) 2
 c) 3
 d) 2.66
 Correct Answer: b) 2
20. Which of the following is not a valid Python identifier?
 a) _myvar
 b) my_var
 c) 2myvar
 d) myVar
 Correct Answer: c) 2myvar
21. Which data type in SQL is used to store Boolean values?
 a) BOOLEAN
 b) INT
 c) BIT
 d) CHAR
 Correct Answer: a) BOOLEAN
22. What is the term used to describe an error in a program that prevents it from running as
expected?
 a) Warning
 b) Bug
 c) Syntax
 d) Exception
 Correct Answer: b) Bug
23. Which of the following keywords is used in Python to catch exceptions?
 a) catch
 b) try
 c) except
 d) error
 Correct Answer: c) except
24. Which of the following is a key feature of Object-Oriented Programming (OOP)?
 a) Procedural
 b) Polymorphism
 c) Sequential
 d) Linear
 Correct Answer: b) Polymorphism
25. In Python, what does the continue statement do?
 a) Pauses the loop
 b) Exits the loop
 c) Skips the rest of the code inside the loop for the current iteration
 d) None of the above
 Correct Answer: c) Skips the rest of the code inside the loop for the current iteration
26. Which SQL statement is used to remove duplicates from the result set?
 a) REMOVE DUPLICATES
 b) DELETE DUPLICATES
 c) SELECT DISTINCT
 d) UNIQUE
 Correct Answer: c) SELECT DISTINCT
27. What does JSON stand for, and what is it primarily used for?
 a) Java Secure Object Notation; securing Java objects
 b) JavaScript Object Notation; transmitting data between a server and web application
 c) Java Simple Object Notation; simplifying Java object serialization
 d) JavaScript Simple Object Notation; simplifying JavaScript object serialization
 Correct Answer: b) JavaScript Object Notation; transmitting data between a server and
web application
28. Which of the following Python data types is typically used for storing a sequence of
characters, such as a paragraph of text?
 a) list
 b) tuple
 c) dictionary
 d) string
 Correct Answer: d) string
29. In the context of database management systems, what does ACID stand for?
 a) Atomicity, Consistency, Isolation, Durability
 b) Analysis, Creation, Implementation, Deletion
 c) Authentication, Confidentiality, Integrity, Defense
 d) Allocation, Compilation, Integration, Development
 Correct Answer: a) Atomicity, Consistency, Isolation, Durability
30. Which of the following is NOT a valid way to start a for loop in Python?
 a) for i in range(5):
 b) for i=0; i < 5; i++:
 c) for i in [0, 1, 2, 3, 4]:
 d) for i in 'hello':
 Correct Answer: b) for i=0; i < 5; i++: (This syntax is incorrect for Python and is more typical
of languages like C or Java.)

Section B

Question 1:
Describe the concept of "Inheritance" in Object-Oriented Programming. Give a Python example to
illustrate simple inheritance. (2 marks)
 Correct Answer: Inheritance is a fundamental concept in object-oriented programming (OOP)
that allows a class (child class) to inherit attributes and methods from another class (parent class).
This mechanism promotes code reusability and a hierarchical classification of classes. For
example:
class Animal:
def speak(self):
print("Animal speaks")

class Dog(Animal):
def bark(self):
print("Dog barks")

# Creating an instance of Dog


dog = Dog()
dog.speak() # Outputs: Animal speaks
dog.bark() # Outputs: Dog barks

This example shows a Dog class inheriting from the Animal class, allowing it to use the speak method
defined in Animal, in addition to its own bark method.
Question 2:
Write an SQL query to select all records from a table Students where the Grade is 'A'. Assume the
table has columns StudentID, Name, and Grade. (2 marks)
 Correct Answer:
SELECT * FROM Students WHERE Grade = 'A';

This SQL query selects all columns for students who have achieved a grade of 'A' in the Students table.
Question 3:
Explain the difference between "Stack" and "Queue" data structures with respect to how data is
added and removed in each. (2 marks)
 Correct Answer: Stack and Queue are two fundamental data structures that differ primarily in
how data is added and removed:
 Stack: Follows the Last In, First Out (LIFO) principle. This means the last element added
to the stack will be the first to be removed. Operations are typically named push (to add
an item) and pop (to remove an item).
 Queue: Follows the First In, First Out (FIFO) principle. This means the first element
added to the queue will be the first to be removed. Operations are commonly referred to
as enqueue (to add an item) and dequeue (to remove an item).
Question 4:
Consider the following Python code snippet:
nums = [10, 20, 30, 40, 50]
nums[2] = nums[2] + 10
print(nums)

What will be the output of the above code, and why? (2 marks)
 Correct Answer: The output of the code will be [10, 20, 40, 40, 50]. This is because the element
at index 2 (which is 30, as indexing starts at 0 in Python) is modified to be 30 + 10, making it 40.
Therefore, the updated list becomes [10, 20, 40, 40, 50], reflecting this change.

5. Write a Python function merge_dictionaries(dict1, dict2) that combines two dictionaries passed as
parameters and returns a new dictionary that contains all the items from both dictionaries. If there is
an overlap, values from dict2 should override those from dict1.

 Correct Answer:
def merge_dictionaries(dict1, dict2):
result = dict1.copy() # Copy all items from dict1 into the result
result.update(dict2) # Update with items from dict2 (overrides if exists)
return result

6. Given the SQL table Orders with columns OrderID, CustomerID, and OrderDate, write an
SQL query to find the total number of orders made by each customer. Sort the result by
CustomerID in ascending order.
 Correct Answer:
SELECT CustomerID, COUNT(OrderID) AS TotalOrders
FROM Orders
GROUP BY CustomerID
ORDER BY CustomerID ASC;
7. Explain the difference between 'Class' and 'Object' in the context of Object-Oriented
Programming (OOP). Provide an example to support your explanation.
 Correct Answer: In OOP, a 'Class' is a blueprint or template for creating objects, defining the
properties (attributes) and behaviors (methods) that the objects created from the class can
have. An 'Object' is an instance of a class, embodying the defined attributes and methods. For
example, if Car is a class with attributes like color and brand, and methods like drive(), an
object of this class could be myCar with color = 'red' and brand = 'Toyota' that can
perform the drive() operation.
8. Describe the term "Normalization" in databases. Why is it important? Provide an example of
converting a table to the First Normal Form (1NF).
 Correct Answer: Normalization is the process of organizing data in a database to reduce
redundancy and improve data integrity. It involves dividing large tables into smaller tables
and defining relationships between them. Normalization is important because it minimizes
duplicate data, simplifies data management, and enhances data consistency. For a table to be
in 1NF, it must have atomic values, meaning each cell contains a single value, not a list or set
of values. Example: Splitting a Students table that contains a Name and Courses (with
multiple courses listed in a single cell) into two tables where Courses are listed in individual
rows for each student.
9. What is the significance of the OSI model in networking? Briefly describe the function of any
two layers of the OSI model.
 Correct Answer: The OSI (Open Systems Interconnection) model is a conceptual framework
used to understand network interactions in seven layers. Each layer serves a specific function
in the process of communicating over a network. For example, the Transport Layer ensures
reliable data transfer between end systems, and the Application Layer provides network
services to end-user applications. This model helps standardize network communications and
allows different network hardware and software to communicate.
10. In Python, how would you handle an exception raised during file operations, such as attempting
to read a file that does not exist? Provide a code snippet.
 Correct Answer:
try:
with open('nonexistent_file.txt', 'r') as file:
data = file.read()
except FileNotFoundError:
print("The file was not found.")

You might also like