PPL Flashcards
In the expression x = 7 + 3 * 6, which operation is performed first?
A. Addition C. Subtraction
B. Multiplication D. Division
B. Multiplication
Who is credited with designing the first widely known compiler?
a) Alick E. Glennie c) John Backus
b) Grace Hopper d) Dennis Ritchie
B. GRACE HOPPER
What kind of programming uses logical deduction rather than sequential steps?
A. Object-Oriented Programming
B. Imperative Programming
C. Functional Programming
D. Logic Programming
D. LOGIC PROGRAMMING
Which of the following is NOT considered a feature of a programming language?
a) Orthogonality c) Type equivalence
b) Control structures d) Debugging mode
D. DEBUGGING MODE
Which paradigm organizes computation around variables and stepwise control of data manipulation?
a) Functional c) Imperative
b) Logic d) Declarative
C. IMPERATIVE
What is the purpose of a variable in programming?**
A. It stores data temporarily in memory
B. It performs mathematical calculations
C. It controls the flow of the program
D. It only stores integers
A. IT STORES DATA TEMPORARILY IN MEMORY
Which of the following languages introduced the concept of object-oriented programming?
a) Simula c) Fortran
b) Pascal d) Prolog
A. SIMULA
Functional programming is based on which mathematical concept?
a) Boolean algebra c) Logic predicates
b) Lambda calculus d) Stored program concept
B. LAMBDA CALCULUS
What type of error occurs if you try to divide an integer by zero in most programming languages?**
A. Syntax error C. Runtime error
B. Compilation error D. Logical error
C. RUNTIME ERROR
Which of the following is a primary aspect of program performance influenced by language features?
a) Expressiveness c) Aliasing
b) Reusability d) Assembly language compatibility
A. EXPRESSIVENESS
What is a common disadvantage of using a compiler over an interpreter?**
A. The compiled code is not portable
B. You must recompile the code after making changes
C. It translates code line by line, which is slower
D. Errors are displayed one at a time during execution
B. You must recompile the code after making changes
Which feature of programming languages supports reuse of code and improves readability and writeability?
a) Control structures c) Abstraction
b) Syntax design d) Type checking
C. ABSTRACTION
In which language paradigm are “classes” and “objects” fundamental concepts?
A. Imperative C. Object-Oriented
B. Functional D. Declarative
C. OBJECT-ORIENTED
What does an assembler do?
A. Translates machine code into assembly
B. Translates assembly language into machine code
C. Interprets high-level languages
D. Debugs programs
B. Translates assembly language into machine code
What does P vs NP in programming refer to?
A. A classification of problems based on difficulty in algorithmic solution
B. A programming language comparison
C. A discussion of hardware limitations
D. The development of new software
A. A classification of problems based on difficulty in algorithmic solution
What is a key difference between a compiler and an interpreter?
A. A compiler runs code line by line
B. An interpreter translates and runs code line by line, while a compiler translates the whole code at once
C. A compiler executes the code immediately
D. An interpreter saves the object code for later use
B. An interpreter translates and runs code line by line, while a compiler translates the whole code at once
When is a while loop typically used?**
A. When you know exactly how many times the code block will execute
B. When there are no conditions to check
C. When you do not know the number of iterations or details of the condition
D. When iterating through a list
C. When you do not know the number of iterations or details of the condition
The paradigm that expresses computation in terms of logic predicates is known as:
a) Declarative
b) Object-oriented
c) Imperative
d) Functional
a) Declarative
Which language was a major influence on the development of structured programming?
a) C++ c) Lisp
b) ALGOL d) Smalltalk
b) ALGOL
Which programming language feature is primarily responsible for improving reliability by preventing programs from crashing due to unexpected circumstances?
a) Expressiveness
b) Exception handling
c) Syntax design
d) Data structures
b) Exception handling
Who invented the binary system and calculus?
A. Alan Turing
B. Gottfried Wilhelm Leibniz
C. Alonzo Church
D. Abu Ja’far Muhammad ibn Musa
B. Gottfried Wilhelm Leibniz
What is a key drawback of highly expressive programming languages?
a) Reduced readability
b) Less reliability
c) Weaker data types
d) Limited exception handling
a) Reduced readability
Which is NOT a characteristic of machine language?
A. Translation-free
B. Error-prone
C. Machine dependent
D. High-level abstraction
D. High-level abstraction
Prolog was originally designed for which application?
a) Object-oriented programming
b) Artificial intelligence
c) Mathematical calculations
d) System implementation
b) Artificial intelligence
Which of the following is a primitive type?
A) Array
B) int
C) Class
D) Structure
B) int
Which data type is most likely a composite type?
A) boolean
B) float
C) Array
D) int
C) Array
What is a characteristic of primitive types?
A) Complex structure
B) Defined by the user
C) Fixed size
D) Customizable size
C) Fixed size
What is a major disadvantage of dynamic typing?
A) Errors may only be detected at runtime
B) Reduced flexibility
C) Increased verbosity
D) None of the above
A) Errors may only be detected at runtime
Which type of typing performs type checking at compile time?
A) Dynamic typing
B) Static typing
C) Weak typing
D) None of the above
B) Static typing
Non-primitive types are also known as:
A) Simple types
B) Complex types
C) Immutable types
D) Built-in types
B) Complex types
In weakly typed languages, implicit type conversion is also called:
A) Type coercion
B) Type annotation
C) Type casting
D) Type deduction
A) Type coercion
Which of the following is not a composite type?
A) Array
B) int
C) List
D) Tuple
B) int
What is a common issue with using pointers?
A) Memory leaks
B) Faster code execution
C) Reduced memory usage
D) None of the above
A) Memory leaks
A scalar type is best defined as:
A) A data type that holds a single value
B) A data type with multiple elements
C) A non-primitive type
D) A complex structure
A) A data type that holds a single value
What is the main advantage of static typing?
A) Greater flexibility
B) Early error detection
C) Faster prototyping
D) Simplified syntax
B) Early error detection
Reference counting in garbage collection is challenged by:
A) Circular references
B) Long strings
C) Large arrays
D) Recursion
A) Circular references
In which languages is dynamic typing commonly found?
A) C, C++
B) Python, JavaScript
C) Java, Swift
D) C#, C++
B) Python, JavaScript
Which type of typing is TypeScript based on?
A) Nominal typing
B) Structural typing
C) Weak typing
D) Dynamic typing
B) Structural typing
Which type system allows for implicit type conversions?
A) Strong typing
B) Weak typing
C) Nominal typing
D) Structural typing
B) Weak typing
Memory allocation that occurs at compile time is called:
A) Static allocation
B) Dynamic allocation
C) On-the-fly allocation
D) Manual allocation
A) Static allocation
Which type of garbage collection is known for handling short-lived objects efficiently?
A) Reference Counting
B) Generational GC
C) Mark and Sweep
D) Static Allocation
B) Generational GC
In which languages is explicit type assignment required?
A) Java, C++
B) Python, JavaScript
C) Swift, TypeScript
D) None of the above
A) Java, C++
Which of the following is a benefit of strong typing?
A) Fewer bugs from unintended type conversions
B) Simplified code structure
C) Improved readability
D) Reduced compile time
A) Fewer bugs from unintended type conversions
Implicit type assignment relies on:
A) User input
B) Type inference
C) Explicit type declaration
D) Variable renaming
B) Type inference
Java primarily uses which type of garbage collection technique?
A) Manual deallocation
B) Reference counting
C) Generational GC
D) Type inference
C) Generational GC
Static allocation is best suited for:
A) Temporary arrays
B) Global constants
C) Short-lived variables
D) Linked lists
B) Global constants
What does type inference help to reduce?
A) Verbosity in code
B) Program correctness
C) Syntax complexity
D) Type mismatch errors
A) Verbosity in code
Which language does not support pointers?
A) Java
B) C
C) C++
D) Assembly
A) Java
A pointer holds:
A) A fixed value
B) An object
C) The memory address of another variable
D) An integer value
C) The memory address of another variable
Which of these is an example of dynamic allocation in C?
A) int array[10];
B) int array = (int)malloc(10 * sizeof(int));
C) int array[] = {1,2,3};
D) int array(10);
B) int array = (int)malloc(10 * sizeof(int));
A strongly-typed language requires:
A) Implicit type declarations
B) Explicitly matching types
C) No type checking
D) Multiple type conversions
B) Explicitly matching types
A benefit of dynamic allocation is:
A) Flexibility in memory usage
B) Faster program execution
C) Reduced program size
D) None of the above
A) Flexibility in memory usage
Which is an example of explicit type assignment?
A) var x = 10;
B) int x = 10;
C) auto x = 10;
D) let x = “text”;
B) int x = 10;
Which of the following languages is weakly typed?
A) JavaScript
B) Java
C) Python
D) Swift
A) JavaScript
Which is an example of user-friendly error handling in web applications?
A) Displaying error codes directly to users
B) Providing helpful, easy-to-understand messages when something goes wrong
C) Ignoring errors completely
D) None of the above
B) Providing helpful, easy-to-understand messages when something goes wrong
What is an expression in programming?
A) A statement that produces a result.
B) A combination of values, variables, operators, and functions that produce a result.
C) A combination of variables and operators without producing a result.
D) None of the above
B) A combination of values, variables, operators, and functions that produce a result.
In which of the following expressions is type coercion most likely to occur?
A) 3 + 4
B) 3 + “4”
C) 3 * 4
D) None of the above
B) 3 + “4”
What is the role of an assignment statement in programming?
A) To create a new variable
B) To evaluate an expression and store the result in a variable
C) To delete a variable
D) None of the above
B) To evaluate an expression and store the result in a variable
Strict evaluation means:
A) Only the necessary parts of an expression are evaluated.
B) All parts of the expression are evaluated before execution continues.
C) Expressions are never evaluated.
B) All parts of the expression are evaluated before execution continues.
Which pattern is useful for operations that may fail temporarily, such as network requests?
A) Retry logic
B) Error suppression
C) Graceful degradation
D) All of the above
A) Retry logic
In programming, what is the primary difference between syntax and semantics?
A) Syntax defines the meaning; semantics defines the structure.
B) Syntax defines the structure; semantics defines the meaning.
C) Both syntax and semantics define meaning.
D) All of the above
B) Syntax defines the structure; semantics defines the meaning.
In Python, which assignment type allows unpacking values from a sequence into individual variables?
A) Chained Assignment
B) Simple Assignment
C) Unpacking Assignment
D) All of the above
C) Unpacking Assignment
What is the purpose of providing descriptive error messages?
A) To hide error details from the user
B) To help developers identify the cause and location of an error
C) To reduce program size
D) All of the above
B) To help developers identify the cause and location of an error
Which type of error occurs due to incorrect program logic but does not crash the program?
A) Syntax error
B) Runtime error
C) Logical error
D) All of the above
C) Logical error
Lazy evaluation is commonly found in which language type?
A) Procedural
B) Functional
C) Object-oriented
D) None of the above
B) Functional
In C++, operator overloading allows:
A) Using different data types with the same operator.
B) Defining new operators.
C) Custom definitions for standard operators on user-defined types.
D) None of the above
C) Custom definitions for standard operators on user-defined types.
In expression typing, what type of language checks types at runtime?
A) Statically-typed
B) Dynamically-typed
C) Weakly-typed
D) None of the above
B) Dynamically-typed
Which language does not have increment (++) and decrement (–) operators?
A) C++
B) Python
C) Java
D) None of the above
B) Python
Aliasing occurs when:
A) Two variables refer to the same memory location
B) A variable is uninitialized
C) Two variables have different values
D) None of the above
A) Two variables refer to the same memory location
What type of assignment allows a value to be assigned to multiple variables at once?
A) Compound Assignment
B) Chained Assignment
C) Simple Assignment
D) None of the above
B) Chained Assignment
Short-circuiting occurs in which types of operations?
A) Arithmetic
B) Logical
C) Bitwise
D) None of the above
B) Logical
The ternary operator in JavaScript has the form:
A) condition ? expr1 : expr2
B) condition && expr1 || expr2
C) expr1 ? condition : expr2
D) None of the above
A) condition ? expr1 : expr2
Copy semantics in assignment means:
A) The variable points to the memory address of the data.
B) The value on the right is copied into the variable on the left.
C) The variable on the left is deleted.
D) None of the above
B) The value on the right is copied into the variable on the left.
Which type of error is detected before the program is executed?
A) Runtime error
B) Syntax error
C) Logical error
D) None of the above
B) Syntax error
Which language has a safe navigation operator?.
A) Python
B) C++
C) Kotlin
D) None of the above
C) Kotlin
Which of the following scenarios benefits from short-circuiting?
A) Executing a function that performs heavy computation
B) Checking if a value is null before accessing its properties
C) Storing values in a database
D) None of the above
B) Checking if a value is null before accessing its properties
Which is a best practice for using short-circuit evaluation?
A) Using nested short-circuit operators in all expressions
B) Keeping conditions clear and avoiding excessive nesting
C) Using & for short-circuiting in C++
D) None of the above
B) Keeping conditions clear and avoiding excessive nesting
The try-catch block is used to:
A) Perform arithmetic operations.
B) Handle runtime errors.
C) Define functions.
D) None of the above
B) Handle runtime errors.
Which example demonstrates the use of short-circuiting to avoid a potential runtime error?
A) if (a / b > 2 && a != 0) {…}
B) if (a != 0 && b / a > 2) {…}
C) if (a == 0 || a / b > 2) {…}
D) None of the above
C) if (a == 0 || a / b > 2) {…}
Which rule helps determine the order in which operations are performed?
A) Associativity
B) Precedence
C) Typing
D) None of the above
B) Precedence
What is the difference between initialization and assignment?
A) Initialization provides an initial value, while assignment updates the variable’s value.
B) Initialization updates the variable, while assignment only provides an initial value.
C) Both are the same.
D) None of the above
A) Initialization provides an initial value, while assignment updates the variable’s value.
Expression trees are used to:
A) Parse expressions.
B) Optimize memory usage.
C) Visualize the order of evaluation.
D) None of the above
C) Visualize the order of evaluation.
To handle overflow during type conversion, a programmer can use:
A) Error handling mechanisms, like try-catch blocks
B) Implicit conversion
C) Uninitialized variables
D) None of the above
A) Error handling mechanisms, like try-catch blocks
A best practice to avoid bugs with type conversions is to:
A) Use implicit conversions only
B) Use explicit conversions whenever possible
C) Avoid conversions altogether
D) None of the above
B) Use explicit conversions whenever possible
Strict evaluation means:
A) Only the necessary parts of an expression are evaluated.
B) All parts of the expression are evaluated before execution continues.
C) Expressions are never evaluated.
D) None of the above
B) All parts of the expression are evaluated before execution continues.