0% found this document useful (0 votes)
20 views

Computer Programming COS 201 (Chapter 1 & 2)

The document contains a series of practice questions related to computer programming concepts, including functional programming, data structures, algorithms, and programming languages. It covers topics such as object-oriented programming, version control, debugging, and specific programming languages like Erlang and Python. Each question presents multiple-choice answers, testing knowledge on fundamental programming principles and practices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Computer Programming COS 201 (Chapter 1 & 2)

The document contains a series of practice questions related to computer programming concepts, including functional programming, data structures, algorithms, and programming languages. It covers topics such as object-oriented programming, version control, debugging, and specific programming languages like Erlang and Python. Each question presents multiple-choice answers, testing knowledge on fundamental programming principles and practices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

PRACTICE QUESTIONS

CHAPTER 1 8. Functional programming is primarily based


on:
1. A complete computer system is made up of a) Procedural paradigms
the following components except: b) Mathematical functions
a) Hardware c) Object-oriented paradigms
b) Operating System Software d) State-changing operations
c) Application Software 9. An example of a pure functional language is:
d) Networking Cables a) Python
2. The component that forms the interface b) Java
between human users and the computer c) Haskell
hardware is: d) C++
a) Application Software 10. Which characteristic is typical of functional
programming?
b) Programming Interface
a) Use of state-changing variables
c) Operating System
b) Higher-order functions and lazy
d) Users
evaluation
3. A computer program is defined as:
c) Flow controls like loops and conditionals
a) A single instruction to direct computer d) Fixed memory allocations
behavior 11. Which is a key advantage of functional
b) A series of step-by-step instructions that programming?
solve a problem a) Mutable state management
c) A physical component of the computer b) Efficient parallel programming without
d) A set of hardware configurations state-change issues
4. Which of the following is a type of computer c) Complex variable management
programming? d) Increased system instability
a) Hardware Programming 12. An operating system is classified as:
b) System Programming a) Application Software
c) Mechanical Programming b) System Software
d) Electrical Programming c) Hardware Component
d) Middleware
5. Computers solve problems by:
13. Which of these is an example of high-level
a) Using intuition and reasoning
programming languages?
b) Following instructions supplied by
a) Assembly language
programmers b) Machine code
c) Guessing the best solution c) Java
d) Combining hardware components d) Binary instructions
6. A key design goal of a good computer 14. A compiler translates:
program is to: a) High-level code to machine code
a) Execute quickly while consuming minimal b) Machine code to assembly language
memory c) Binary code to ASCII
b) Focus solely on aesthetics d) Programming concepts to natural
c) Increase hardware costs language
d) Avoid documentation 15. The basic control structures in programming
7. Which of the following is not an aim of good include all except:
computer program design? a) Sequence
b) Selection
a) Reliability
c) Iteration
b) Portability
d) Compiling
c) Maintainability
d) Inflexibility Made with love by THRIVE LINK
16. Which of the following programming c) To process user input
paradigms focuses on objects and their d) To manage system memory
interactions?
a) Procedural programming 25. What is an algorithm in computer
b) Functional programming programming?
c) Object-oriented programming a) A hardware component of the computer
d) Assembly language programming b) A step-by-step procedure for solving a
17. A loop that continues until a condition problem
becomes false is an example of: c) A type of programming language
a) Selection control d) A method for debugging programs
b) Iteration control 26. In programming, what is a syntax error?
c) Compilation a) An error caused by incorrect logic in the
d) Recursion code
18. In object-oriented programming, b) An error caused by invalid grammar in
encapsulation refers to: the code
a) Bundling data and methods together c) An error that occurs during program
b) Separating functions into distinct modules execution
c) Sharing variables globally across programs d) An error caused by the operating system
d) Allowing unrestricted data access 27. What does the acronym "HTML" stand for?
19. Which of the following is not a common data a) Hyper Text Markup Language
structure? b) High-Level Text Markup Language
a) Array c) Hyper Transfer Machine Language
b) Linked list d) Hyper Text Managing Logic
c) Compiler
28. In software development, what is the
d) Hash map purpose of testing?
20. Which principle aims to ensure that code is a) To write user manuals
clear, concise, and easy to maintain? b) To find and fix errors in the program
a) DRY (Don't Repeat Yourself)
c) To increase the size of the program
b) WET (Write Everything Twice) d) To remove unnecessary code
c) NOP (No Operations Performed)
29. Which of these data structures is linear?
d) FAT (Fast and Tangled) a) Tree
21. Debugging refers to: b) Graph
a) Writing new programs c) Stack
b) Finding and fixing errors in code d) Network
c) Designing system architecture 30. What does the acronym "IDE" stand for in
d) Compiling code to binary format programming?
22. What is the main purpose of version control a) Internal Development Environment
systems in software development? b) Integrated Development Environment
a) Organizing user files c) Independent Data Encoder
b) Tracking changes to code over time d) Interactive Debugging Engine
c) Debugging programs 31. Which of the following is a characteristic of
d) Creating documentation high-level programming languages?
23. Which of the following is an example of an a) Machine-dependent
input device? b) Easy for humans to understand
a) Monitor c) Requires assembly translation
b) Printer d) Provides direct hardware control
c) Keyboard
32. What is the purpose of the "if" statement in
d) Speaker programming?
24. What is the main function of secondary a) To repeat code
storage? b) To define a variable
a) To execute programs c) To makeMade
decisions based
b) To store data permanently with love byon conditions
THRIVE LINK
d) To create loops
33. In object-oriented programming, what does
41. In function overloading, functions are said to
the term "class" refer to?
be overloaded if:
a) A variable in a program
a) They have the same name and same
b) A blueprint for creating objects
number of arguments
c) A method to call a function
b) They have different names but return the
d) A loop for program iteration
same type
34. Which of the following is NOT an operating
c) They have the same name but different
system?
argument lists
a) Linux
d) They use the same return type but
b) Windows
different names
c) Microsoft Office
42. Function overriding occurs when:
d) macOS
a) A function in a child class has the same
35. What is the main role of a compiler in
signature as a function in the parent class
programming?
b) Functions in the same class share the
a) To execute code line by line
same name but different arguments
b) To translate source code into machine
c) A function returns different types in
code
different executions
c) To debug errors in the program
d) A recursive function calls itself
d) To provide graphical user interfaces
43. What is the output when the following code
36. What is the purpose of using comments in
is executed for fact(5)?
programming?
a) To execute hidden code def fact(n):
b) To document code for better if n == 1:
understanding return n
c) To create additional variables else:
d) To increase code efficiency return n * fact(n-1)
37. What is the binary number system primarily
a) 15
used for in computers?
b) 25
a) To store large amounts of data
c) 120
b) To represent data in 0s and 1s
d) 720
c) To perform decimal calculations
44. Which of the following is NOT true about
d) To design hardware components
Higher-Order Functions (HOFs)?
38. Which of the following is an example of a
a) They can take other functions as
loop structure?
arguments
a) If-else
b) They can return a function as a result
b) Switch-case
c) They cannot use lambda functions
c) For
d) They can perform operations on functions
d) Break
45. What is the output of the following code?
39. In Python, which of these is used to define a
function?
def twice(function):
a) def
return lambda x: function(function(x))
b) func g = twice(lambda x: x + 3)
c) method print(g(7))
d) create
40. A recursive function is one that:
a) 10
a) Is executed only once
b) 13
b) Calls itself repeatedly
c) 16
c) Cannot call other functions
d) 21
d) Is part of higher-order functions

Made with love by THRIVE LINK


46. Which of the following is NOT a fundamental 53. What is a tuple in Erlang?
data type? a) A collection of key-value pairs
a) Integer b) A fixed-size compound data type
b) Array c) A sequence of characters
c) Float d) A variable-size compound data type
d) Character 54. How can you determine the size of a tuple in
47. User-defined data types: Erlang?
a) Are created by programmers using built- a) size(tuple_name)
in data types b) tuple_size(tuple_name)
b) Are predefined in programming languages c) length(tuple_name)
c) Cannot store multiple values d) count(tuple_name)
d) Do not allow customization of data 55. What is a map in Erlang?
structures a) A list of values
48. In function overriding, what must be the b) A fixed-size data structure
same in both base and derived classes? c) A key-value data structure
a) Function name and arguments d) A set of tuples
b) Return type 56. How can you determine the size of a map in
c) Both function name and return type Erlang?
d) Function name, arguments, and return a) size(Map)
type b) length(Map)
49. Erlang supports two types of numeric literals. c) map_size(Map)
They are: d) count(Map)
a) int and float 57. What is a list in Erlang?
b) char and int a) A fixed-size data type
c) string and float b) A sequence of characters
d) tuple and list c) A compound data type with a variable
50. Which type of data types are designed to number of elements
store multiple values of the same type as per d) A key-value data structure
the requirement? 58. How can you find the number of elements in
a) Fundamental data types a list?
b) Derived data types a) size(List)
c) User-defined data types b) tuple_size(List)
d) None of the above c) list_size(List)
51. Which of the following is not a fundamental d) length(List)
data type? 59. What is a string in Erlang?
a) int a) A sequence of integers
b) char b) A NULL-terminated array of characters
c) float c) A list of characters
d) List d) A tuple of characters
52. What is the output of this code? 60. Which function is used to concatenate two
strings in Erlang?
class X:
a) append(S1, S2)
def disp(self):
print("Base Class") b) concat(S1, S2)
class Y(X): c) join(S1, S2)
def disp(self): d) merge(S1, S2)
print("Derived Class") 61. What will to_lower(S1) do in Erlang?
y = Y() a) Convert S1 to uppercase
y.disp()
b) Convert S1 to lowercase
a) Base Class c) Reverse the string
b) Derived Class d) Remove spaces from S1
c) Error Made with love by THRIVE LINK
d) None
62. Which function returns the number of c) Map#{ Key => Value }
characters in a string? d) add(Map, Key, Value)

a) size(S1) 70. What will hd([1,2,3,4]) return?


b) length(S1)
a) [1]
c) count(S1)
b) 1
d) string_size(S1)
c) [1,2]
63. What does substr(S1, S2, Num) do? d) [2,3,4]

a) Replaces S2 with Num in S1 71. What does tl([10,20,30,40]) return?


b) Returns the substring S2 from S1 starting
a) 10
at Num
b) [20,30,40]
c) Removes Num characters from S1
c) [10]
d) Converts S1 to uppercase
d) [30,40]
64. What does equals(S1, S2) return?
a) true if S1 and S2 are equal, otherwise 72. What is the difference between a list and a
false tuple in Erlang?
b) Concatenates S1 and S2
a) A tuple is dynamic, while a list is fixed-size
c) Returns the length of both strings
b) A list is immutable, while a tuple is
d) Converts both strings to lowercase
mutable
65. Which function removes the last element
c) A tuple has a fixed size, while a list can
from a list?
grow dynamically
a) delete_last(List)
d) A list can contain different data types,
b) remove_last(List)
while a tuple cannot
c) drop_last(List)
d) trim_last(List) 73. What does the member(element, listname)
66. Which function is used to add two lists in method do in Erlang?
Erlang?
a) Searches for an element in a tuple
a) join(List1, List2)
b) Finds the maximum value in a list
b) concat(List1, List2)
c) Searches for an element in a list
c) append(List1, List2)
d) Sorts a list in descending order
d) merge(List1, List2)
67. What is the output of the following Erlang 74. Which method is used to find the maximum
program? value in a list in Erlang?
S1 = "Today is",
S2 = " Monday", a) max(listname)
S3 = concat(S1, S2), b) min(listname)
io:fwrite("~p~n", [S3]). c) sort(listname)
d) reverse(listname)
a) Today isMonday
b) Today is Monday 75. How do you sort a list in ascending order in
c) Today isMonday\n Erlang?
d) Monday Today is a) sort_desc(listname)
68. How do you retrieve a value from a map in b) sort(listname)
Erlang? c) reverse(listname)
a) map:get(Key, Map) d) member(listname)
b) Map[Key] 76. What does the sum(listname) method do?
c) lookup(Key, Map)
d) get_value(Key, Map) a) Returns the number of elements in the list
69. How do you add a new key-value pair to a b) Adds all the elements of a list
map in Erlang? c) Finds the median of a list
Made awith
d) Converts list love by THRIVE LINK
to a tuple
a) Map[Key] = Value
b) put(Key, Value, Map)
77. What is the output of the following Erlang 84. How do you access a record's field in Erlang?
function for the list [5,3,4,2,1]? a) recordname.fieldname
b) #recordname.fieldname
c) recordname->fieldname
io:fwrite("~p~n",[sort(List1)])
d) fieldname(recordname)
85. What is the output of the following code?

a) [1,2,3,4,5]
-record(student, {sname = "", sid})
b) [5,4,3,2,1]
S = #student{sname = "Samuel", sid = 5}
c) [1,5,4,2,3] S#student.sname
d) [3,2,5,4,1]
78. Which function converts a list to a tuple?
a) Samuel
a) tuple_to_list()
b) 5
b) list_to_tuple()
c) {Samuel, 5}
c) to_tuple()
d) Error
d) tuple_convert()
86. What is the keyword used to define records
79. Which function converts a tuple to a list?
in Erlang?
a) tuple_to_list()
a) tuple
b) list_to_tuple()
b) list
c) to_list()
c) record
d) convert_tuple()
d) define
80. How do you determine the size of a tuple in
87. Which method is used to update a record
Erlang?
value?
a) list_size(tuple)
a)Redefine the record completely
b) tuple_count(tuple)
b) Change the specific field and assign to a
c) tuple_size(tuple)
new variable
d) size(tuple)
c) Use the update_field method
81. What is the output of the following code
d) Use the change_record method
snippet?
88. Which of the following is not an operation on
tuple_to_list({1,2,3,4,5}) tuples?
a) tuple_to_list()
b) tuple_size()
a) [1,2,3,4,5]
c) tuple_concat()
b) {1,2,3,4,5}
d) is_tuple()
c) [5,4,3,2,1]
89. What is the size of the tuple {abc, 50, pqr, 60,
d) {5,4,3,2,1}
{xyz, 75}}?
82. What is the syntax for defining a record in
a) 5
Erlang?
b) 4
a) record_name(field1, field2, ...)
c) 6
b) record(recordname, {field1, field2, ...})
d) 2
c) {recordname, field1, field2}
90. What does the is_tuple() function check?
d) tuple(recordname, field1, field2)
a) If the value is a tuple
83. What does the following syntax achieve?
b) If the tuple is empty
c) If the tuple contains integers only
-record(student, {sname = "", sid})
d) If the tuple has a specific size
91. How do you define a tuple in Erlang?
a) Defines a tuple named "student"
a) {element1, element2, ...}
b) Defines a record with fields sname and
b) [element1, element2, ...]
sid
c) (element1, element2, ...)
c) Defines a list with default values
d) tuple(element1, element2, ...)
d) Defines a record with fixed values
Made with love by THRIVE LINK
92. What does the following Erlang record b) Variables, function applications, and
declaration represent? function creations
c) Constants, operations, and data types
-record(student, {sname = "", sid}) d) Variables, records, and modules

99. Why can't the Lambda Calculus expression (+


a) A function definition (* 5 6) (* 8 3)) start with the + operation?
B. A tuple with named fields
a) The + operator is undefined in Lambda
C. A record structure with fields sname and
Calculus
sid
b) Lambda Calculus only supports
d) A module definition
multiplication
93. In the given Erlang code, what will be the
c) The + operator requires numeric
output of the following statement?
arguments, which need to be evaluated first
d) The syntax for addition is incorrect
io:fwrite("~p~n", [S1#student.sname])
100. What does Beta reduction in lambda
a) Samuel calculus involve?
b) Johnson
a) Changing variable names
c) student
b) Replacing formal parameters with actual
d) Undefined
arguments
94. What is the purpose of the #student syntax
c) Replacing free variables with constants
in Erlang?
d) None of the above
a) To access a tuple value
101. What does Alpha reduction in lambda
b) To access or define a record field
calculus allow?
c) To create a new module
a) Renaming of bound variables
d) To evaluate a lambda function
b) Replacing free variables with constants
95. What is Lambda Calculus primarily used for?
c) Adding a new bound variable
a) Defining variables in functional
d) Removing free variables
programming
102. What is a bound variable in lambda
b) Studying computations with functions
calculus?
c) Sorting and manipulating lists
a) A variable not associated with any lambda
d) Representing records in a database
abstraction
96. In Lambda Calculus, what does the
b) A variable defined within a lambda
expression λx.E represent?
abstraction
a) A tuple abstraction
c) A variable replaced during Beta reduction
b) A variable declaration
d) None of the above
c) A function creation, where x is the
103. Which Python function demonstrates
argument and E is the functional body
lazy evaluation?
d) A predefined function
a) range()
97. What is the result of evaluating the following
b) len()
Lambda Calculus expression?
c) map()
(+ (* 5 6) (* 8 3)) d) all of the above
104. What is the output of the following
code?
a) 64
b) 54 r = range(5)
c) 74 print(list(r))
d) 44
a) [0, 1, 2, 3]
98. In Lambda Calculus, what are the three types
b) [1, 2, 3, 4, 5]
of expressions included in the syntax?
c) [0, 1, 2, 3, 4]
a) Functions, variables, and lists
Made with love by THRIVE LINK
d) Error
105. Why is lazy evaluation beneficial for the c) readline()
range() function? d) None of the above

a) Reduces execution time 114. What does range(2, 5) generate in


b) Minimizes memory consumption Python?
c) Simplifies syntax
a) [2, 3, 4]
d) Both a and b
b) [2, 3, 4, 5]
106. What does range(2, 5) generate in
c) [3, 4, 5]
Python?
d) [2, 4, 5]
a) [2, 3, 4]
115. Which of the following is NOT a
b) [2, 3, 4, 5]
characteristic of lazy evaluation?
c) [3, 4, 5]
a) Saves memory
d) [2, 4, 5]
b) Delays computation
107. Which of the following is NOT a
c) Uses additional storage
characteristic of lazy evaluation?
d) Executes code only when required
a) Saves memory
116. What is the correct mode to open a file
b) Delays computation
for writing in Python?
c) Uses additional storage
a) "r"
d) Executes code only when required
b) "w"
108. What is the correct mode to open a file
c) "a"
for writing in Python?
d) "rw"
a) "r"
117. If a file opened in write mode does not
b) "w"
exist, what happens?
c) "a"
a) The operation fails
d) "rw"
b) A new file is created
109. If a file opened in write mode does not
c) The existing file is updated
exist, what happens?
d) None of the above
a) The operation fails
b) A new file is created 118. Why is lazy evaluation beneficial for the
c) The existing file is updated range() function?
d) None of the above
a) Reduces execution time
110. Which command is used in Erlang to
b) Minimizes memory consumption
write to a file?
c) Simplifies syntax
a) file:read_file()
d) Both a and b
b) file:open()
119. What happens if you attempt to read a
c) file:write()
file that does not exist in Erlang?
d) file:delete()
a) An error is returned
111. What does the file:delete() function in
b) A new file is created
Erlang do?
c) A null value is returned
a) Deletes the contents of a file
d) The program exits
b) Deletes the specified file
120. In Python, how do you close a file after
c) Renames the specified file
operations?
d) Updates the contents of a file
a) close(file)
112. What is the purpose of the
b) file.close()
filelib:file_size() function in Erlang?
c) close()
a) Determine the size of a file in bytes
d) shutdown(file)
b) Read the contents of a file
c) Write data to a file
d) Delete a file
113. Which method in Python reads the
entire content of a file?
Made with love by THRIVE LINK
a) readlines()
b) read()
121. Which command is used in Erlang to
write to a file?

a) file:read_file()
b) file:open()
c) file:write()
d) file:delete()
122. What does the file:delete() function in
Erlang do?
a) Deletes the contents of a file
b) Deletes the specified file
c) Renames the specified file
d) Updates the contents of a file
123. What is the purpose of the
filelib:file_size() function in Erlang?
a) Determine the size of a file in bytes
b) Read the contents of a file
c) Write data to a file
d) Delete a file
124. Which method in Python reads the
entire content of a file?
a) readlines()
b) read()
c) readline()
d) None of the above
105. What is the default mode when opening
a file in Python?
a) Read mode
b) Write mode
c) Append mode
d) Execute mode
106. What does the a mode do when
opening a file in Python?
a) Overwrites the file
b) Appends data to the file
c) Reads the file contents
d) Deletes the file

Made with love by THRIVE LINK


CHAPTER 2 7. Which of the following best describes a key
feature of declarative programming?
1. What is the primary focus of declarative
a) Developer specifies "how" a task is
programming?
performed
a) Specifying step-by-step instructions
b) Developer defines "what" the desired
b) Expressing the logic of computation
results are
c) Writing low-level machine code
c) It is always compiled into machine code
d) Managing hardware resources
d) It requires extensive control structures
2. How does declarative programming differ
8. Which statement is true about declarative
from imperative programming?
programming?
a) It focuses on "how" to achieve results
a) It mandates detailed implementation of
b) It emphasizes "what" the outcome
logic
should be
b) It focuses on describing the desired
c) It is primarily used for system-level
output
programming
c) It is used exclusively for web development
d) It requires detailed control flow
d) It is less abstract than imperative
management
programming
3. Which of the following is a characteristic of
9. What is a common application of declarative
declarative programming?
programming?
a) Step-by-step execution
a) Algorithm optimization
b) Direct hardware interaction
b) Database querying
c) High-level abstraction of logic
c) Hardware simulation
d) Manual memory management
d) Kernel development
4. Which paradigm requires developers to
10. Functional programming is a subset of which
specify the control flow explicitly?
programming paradigm?
a) Declarative programming
a) Procedural programming
b) Imperative programming
b) Declarative programming
c) Functional programming
c) Object-oriented programming
d) Logic programming
d) Structured programming
5. Which of the following is an example of a
11. In which paradigm are "side effects"
declarative programming language?
minimized or eliminated?
a) Java
a) Imperative programming
b) C++
b) Functional programming
c) SQL
c) Procedural programming
d) Assembly
d) Object-oriented programming
6. What is the primary advantage of declarative
12. Which of the following is a key advantage of
programming?
declarative programming in database
a) Easier debugging
management?
b) Simplified syntax
c) Focus on outcomes rather than process Made with love by THRIVE LINK
d) Faster execution
a) Automatic index creation 18. What is a common feature of declarative
b) Direct control of query execution languages like SQL?
c) Simplified querying with SQL a) Ability to define how data is retrieved
d) Manual memory allocation b) Focus on describing what data is
13. Which of the following is a disadvantage of required
declarative programming? c) Requirement for procedural logic
a) Difficult to learn syntax d) Dependency on hardware-specific
b) Lack of abstraction instructions
c) Limited control over low-level execution 19. Which of the following is NOT a feature of
d) Complex implementation details declarative programming?
14. What type of programming paradigm is a) High-level abstraction
Prolog most associated with? b) Specifying desired outcomes
a) Imperative programming c) Explicit control flow
b) Declarative programming d) Logic-driven computation
c) Procedural programming 20. In declarative programming, how is
d) Object-oriented programming program correctness typically verified?
15. Which of the following terms is closely a) By debugging control flow
associated with declarative programming? b) By testing desired outcomes
a) Loops c) By manually analyzing execution paths
b) Control structures d) By stepping through procedural
c) Recursion instructions
d) Logic 21. What is the fundamental purpose of
16. What is the main goal of declarative predicates in logic programming?
programming? a) To store large data
a) Increase performance by managing b) To represent properties or
hardware relationships among entities
b) Simplify coding by focusing on the c) To perform mathematical calculations
desired outcome d) To replace conditional statements
c) Reduce abstraction in program design 22. Which of the following correctly
d) Focus on algorithm optimization represents a rule in logic programming?
17. Which of the following examples best fits a) is_pet(dog).
declarative programming? b) mammal(X) :- is_pet(X).
a) Writing a for loop to iterate through an c) ?- is_pet(dog).
array d) dog :- mammal(X).
b) Describing the data structure of a 23. What is the primary function of queries in
webpage using HTML logic programming?
c) Implementing a sorting algorithm a) Defining new rules
manually b) Retrieving information from the
d) Managing memory allocation in C Madebase
knowledge with love by THRIVE LINK
c) Declaring constants
d) Removing existing facts 29. In logic programming, backtracking is
24. In logic programming, variables are used when:
typically represented using: a) The system needs to search alternative
a) Numbers paths if an initial query fails
b) Uppercase letters (e.g., X, Y, Z) b) The system wants to delete incorrect
c) Special symbols (@, #, &) rules
d) Lowercase letters c) A fact is missing and needs to be
25. What is unification in logic programming? inferred
a) The process of creating new facts d) A predicate needs to be redefined
b) The process of substituting variables to 30. Which of the following is NOT a common
make logical expressions identical application of logic programming?
c) A method of removing inconsistencies in a) Artificial intelligence
rules b) Decision-making processes
d) The process of converting rules into c) Graphics rendering
functions d) Knowledge representation
26. Resolution in logic programming is mainly 31. How is logic programming different from
used for: procedural programming?
a) Proving the truth by contradiction a) It focuses on step-by-step execution
b) Defining new relationships between rather than relationships
entities b) It emphasizes relationships and
c) Declaring rules with multiple conditions constraints rather than specific steps
d) Improving the speed of execution c) It requires loops and conditional
27. Which of the following is a key feature of statements for execution
forward chaining inference? d) It is only useful for mathematical
a) It starts with known facts and applies computations
rules to derive new facts 32. In expert systems, logic programming is
b) It starts with a goal and works backward primarily used to:
to verify conditions a) Simulate human-like reasoning
c) It focuses on finding inconsistencies in b) Improve system performance by
rules reducing execution time
d) It ignores existing facts and creates new c) Process large datasets in databases
ones d) Create graphical user interfaces
28. What is backward chaining primarily used 33. Which logical inference method
for? combines facts and rules to derive
a) Generating new rules dynamically conclusions?
b) Checking conditions to prove a given a) Forward chaining
goal b) Backward chaining
c) Randomly selecting facts from the c) Resolution
database Made with love by THRIVE LINK
d) Unification
d) Removing unused predicates
34. The process of contradiction elimination is 40. What is a major disadvantage of client-side
mainly associated with: scripting?
a) Resolution inference a) Requires powerful server hardware
b) Unification inference b) Cannot validate user input
c) Backtracking inference c) Security risks such as cross-site
d) Knowledge representation scripting (XSS)
35. In logic programming, the main role of d) Does not work in web browsers
unification in inference is to: 41. Which of the following is a server-side
a) Identify matching variables in rules and scripting language?
facts a) JavaScript
b) Prove statements true by contradiction b) PHP
c) Search for the shortest path in c) CSS
reasoning d) HTML
d) Replace predicates dynamically 42. What is a key disadvantage of server-side
36. What is a script in the context of scripting scripting?
languages? a) Increases server load
a) A large standalone program b) Reduces security risks
b) A file containing a list of commands to c) Only runs on web browsers
be interpreted d) Does not support database integration
c) A compiled executable file 43. Which scripting type is used to automate
d) A database management system tasks in a command-line environment?
37. Which of the following was one of the a) Client-side scripting
earliest scripting languages? b) Server-side scripting
a) Python c) Shell scripting
b) Bash d) Embedded scripting
c) JavaScript 44. What is an example of an embedded
d) Ruby scripting language?
38. What is the primary advantage of client- a) Bash
side scripting? b) Lua
a) Reduces server load and bandwidth c) HTML
usage d) MySQL
b) Increases security of web applications 45. What is one of the advantages of
c) Runs only on the server embedded scripting?
d) Requires user authentication a) Requires compiling before execution
39. Which of the following is NOT a client-side b) Increases application complexity
scripting language? c) Provides flexibility to modify
a) JavaScript application behavior
b) HTML d) Requires a separate database for
c) PHP executionMade with love by THRIVE LINK
d) CSS
46. Which of the following is a disadvantage of 52. Why is commenting and documentation
Embedded Scripting? important in scripting?
a) Increased performance a) To increase file size
b) Enhanced security b) To explain complex logic and improve
c) Performance overhead if not optimized code readability
d) Standalone capabilities c) To confuse developers
47. Which of these is an example of a Domain- d) To make debugging harder
Specific Scripting language? 53. What is the purpose of using try-catch
a) Java blocks in error handling?
b) MATLAB a) To ignore errors
c) Python b) To stop program execution
d) C++ c) To handle exceptions gracefully
48. What is an advantage of Domain-Specific d) To remove debugging messages
Scripting languages? 54. Why should user input be validated in
a) Generalized functionality scripting?
b) Tailored features for specific tasks a) To slow down execution speed
c) High learning curve for all users b) To prevent security vulnerabilities such
d) Limited usability as SQL injection
49. One major disadvantage of Domain- c) To make scripts difficult to read
Specific Scripting is: d) To avoid using variables
a) Limited use outside their intended 55. How can performance optimization be
domain achieved in scripting?
b) High computational power a) Using global variables extensively
c) Lack of specific libraries b) Avoiding profiling tools
d) Poor user documentation c) Using efficient data structures
50. Which of the following is a best practice in d) Not using any validation
scripting languages? 56. Which version control system is
a) Writing all code in a single function recommended for managing project
b) Using vague variable names versions?
c) Breaking code into smaller, reusable a) Git
modules b) Notepad
d) Avoiding comments c) Excel
51. What is the best approach for naming d) CMD
variables, functions, and classes? 57. What is the benefit of conducting code
a) Using random names reviews?
b) Following consistent naming a) It helps catch bugs and improve code
conventions like camelCase or snake_case quality
c) Using single-character variable names b) It makes development slower
d) Changing naming conventions Madesecurity
c) It increases with love by THRIVE LINK
risks
frequently d) It decreases collaboration
58. Why should automated testing be used in
scripting?
a) To reduce debugging time and validate
functionality
b) To introduce more errors
c) To replace human programmers
d) To make scripts run slower
59. What is a key security practice when
writing scripts?
a) Allowing unrestricted user input
b) Sanitizing inputs to prevent SQL
injection
c) Granting all users full access
d) Running scripts with administrator
privileges unnecessarily
60. Why is it important to stay updated with
scripting language developments?
a) To learn the latest best practices and
security updates
b) To avoid writing efficient code
c) To reduce collaboration in teams
d) To ignore new features

Made with love by THRIVE LINK


Made with love by THRIVE LINK

You might also like