PPL Flashcards

1
Q

In the expression x = 7 + 3 * 6, which operation is performed first?

A. Addition C. Subtraction
B. Multiplication D. Division

A

B. Multiplication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Who is credited with designing the first widely known compiler?

a) Alick E. Glennie c) John Backus
b) Grace Hopper d) Dennis Ritchie

A

B. GRACE HOPPER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What kind of programming uses logical deduction rather than sequential steps?

A. Object-Oriented Programming
B. Imperative Programming
C. Functional Programming
D. Logic Programming

A

D. LOGIC PROGRAMMING

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is NOT considered a feature of a programming language?

a) Orthogonality c) Type equivalence
b) Control structures d) Debugging mode

A

D. DEBUGGING MODE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which paradigm organizes computation around variables and stepwise control of data manipulation?

a) Functional c) Imperative
b) Logic d) Declarative

A

C. IMPERATIVE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A. IT STORES DATA TEMPORARILY IN MEMORY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following languages introduced the concept of object-oriented programming?

a) Simula c) Fortran
b) Pascal d) Prolog

A

A. SIMULA

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Functional programming is based on which mathematical concept?

a) Boolean algebra c) Logic predicates
b) Lambda calculus d) Stored program concept

A

B. LAMBDA CALCULUS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

C. RUNTIME ERROR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A. EXPRESSIVENESS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

B. You must recompile the code after making changes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

C. ABSTRACTION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In which language paradigm are “classes” and “objects” fundamental concepts?

A. Imperative C. Object-Oriented
B. Functional D. Declarative

A

C. OBJECT-ORIENTED

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

B. Translates assembly language into machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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. A classification of problems based on difficulty in algorithmic solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

A

B. An interpreter translates and runs code line by line, while a compiler translates the whole code at once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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

A

C. When you do not know the number of iterations or details of the condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The paradigm that expresses computation in terms of logic predicates is known as:

a) Declarative
b) Object-oriented
c) Imperative
d) Functional

A

a) Declarative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which language was a major influence on the development of structured programming?

a) C++ c) Lisp
b) ALGOL d) Smalltalk

A

b) ALGOL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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

A

b) Exception handling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Who invented the binary system and calculus?

A. Alan Turing
B. Gottfried Wilhelm Leibniz
C. Alonzo Church
D. Abu Ja’far Muhammad ibn Musa

A

B. Gottfried Wilhelm Leibniz

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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

a) Reduced readability

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Which is NOT a characteristic of machine language?

A. Translation-free
B. Error-prone
C. Machine dependent
D. High-level abstraction

A

D. High-level abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Prolog was originally designed for which application?

a) Object-oriented programming
b) Artificial intelligence
c) Mathematical calculations
d) System implementation

A

b) Artificial intelligence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Which of the following is a primitive type?

A) Array
B) int
C) Class
D) Structure

A

B) int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Which data type is most likely a composite type?

A) boolean
B) float
C) Array
D) int

A

C) Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is a characteristic of primitive types?

A) Complex structure
B) Defined by the user
C) Fixed size
D) Customizable size

A

C) Fixed size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

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

A) Errors may only be detected at runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Which type of typing performs type checking at compile time?

A) Dynamic typing
B) Static typing
C) Weak typing
D) None of the above

A

B) Static typing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Non-primitive types are also known as:

A) Simple types
B) Complex types
C) Immutable types
D) Built-in types

A

B) Complex types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

In weakly typed languages, implicit type conversion is also called:

A) Type coercion
B) Type annotation
C) Type casting
D) Type deduction

A

A) Type coercion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Which of the following is not a composite type?

A) Array
B) int
C) List
D) Tuple

A

B) int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

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

A) Memory leaks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

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) A data type that holds a single value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What is the main advantage of static typing?

A) Greater flexibility
B) Early error detection
C) Faster prototyping
D) Simplified syntax

A

B) Early error detection

36
Q

Reference counting in garbage collection is challenged by:

A) Circular references
B) Long strings
C) Large arrays
D) Recursion

A

A) Circular references

37
Q

In which languages is dynamic typing commonly found?

A) C, C++
B) Python, JavaScript
C) Java, Swift
D) C#, C++

A

B) Python, JavaScript

38
Q

Which type of typing is TypeScript based on?

A) Nominal typing
B) Structural typing
C) Weak typing
D) Dynamic typing

A

B) Structural typing

39
Q

Which type system allows for implicit type conversions?

A) Strong typing
B) Weak typing
C) Nominal typing
D) Structural typing

A

B) Weak typing

40
Q

Memory allocation that occurs at compile time is called:

A) Static allocation
B) Dynamic allocation
C) On-the-fly allocation
D) Manual allocation

A

A) Static allocation

41
Q

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

A

B) Generational GC

42
Q

In which languages is explicit type assignment required?

A) Java, C++
B) Python, JavaScript
C) Swift, TypeScript
D) None of the above

A

A) Java, C++

43
Q

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

A) Fewer bugs from unintended type conversions

44
Q

Implicit type assignment relies on:

A) User input
B) Type inference
C) Explicit type declaration
D) Variable renaming

A

B) Type inference

45
Q

Java primarily uses which type of garbage collection technique?

A) Manual deallocation
B) Reference counting
C) Generational GC
D) Type inference

A

C) Generational GC

46
Q

Static allocation is best suited for:

A) Temporary arrays
B) Global constants
C) Short-lived variables
D) Linked lists

A

B) Global constants

47
Q

What does type inference help to reduce?

A) Verbosity in code
B) Program correctness
C) Syntax complexity
D) Type mismatch errors

A

A) Verbosity in code

48
Q

Which language does not support pointers?

A) Java
B) C
C) C++
D) Assembly

A

A) Java

49
Q

A pointer holds:
A) A fixed value
B) An object
C) The memory address of another variable
D) An integer value

A

C) The memory address of another variable

50
Q

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);

A

B) int array = (int)malloc(10 * sizeof(int));

51
Q

A strongly-typed language requires:

A) Implicit type declarations
B) Explicitly matching types
C) No type checking
D) Multiple type conversions

A

B) Explicitly matching types

52
Q

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

A) Flexibility in memory usage

53
Q

Which is an example of explicit type assignment?

A) var x = 10;
B) int x = 10;
C) auto x = 10;
D) let x = “text”;

A

B) int x = 10;

54
Q

Which of the following languages is weakly typed?

A) JavaScript
B) Java
C) Python
D) Swift

A

A) JavaScript

55
Q

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

A

B) Providing helpful, easy-to-understand messages when something goes wrong

56
Q

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

A

B) A combination of values, variables, operators, and functions that produce a result.

57
Q

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

A

B) 3 + “4”

58
Q

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

A

B) To evaluate an expression and store the result in a variable

59
Q

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.

A

B) All parts of the expression are evaluated before execution continues.

60
Q

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

A) Retry logic

61
Q

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

A

B) Syntax defines the structure; semantics defines the meaning.

62
Q

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

A

C) Unpacking Assignment

63
Q

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

A

B) To help developers identify the cause and location of an error

64
Q

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

A

C) Logical error

65
Q

Lazy evaluation is commonly found in which language type?

A) Procedural
B) Functional
C) Object-oriented
D) None of the above

A

B) Functional

66
Q

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

A

C) Custom definitions for standard operators on user-defined types.

67
Q

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

A

B) Dynamically-typed

68
Q

Which language does not have increment (++) and decrement (–) operators?

A) C++
B) Python
C) Java
D) None of the above

A

B) Python

69
Q

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

A) Two variables refer to the same memory location

70
Q

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

A

B) Chained Assignment

71
Q

Short-circuiting occurs in which types of operations?

A) Arithmetic
B) Logical
C) Bitwise
D) None of the above

A

B) Logical

72
Q

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

A) condition ? expr1 : expr2

73
Q

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

A

B) The value on the right is copied into the variable on the left.

74
Q

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

A

B) Syntax error

75
Q

Which language has a safe navigation operator?.

A) Python
B) C++
C) Kotlin
D) None of the above

A

C) Kotlin

76
Q

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

A

B) Checking if a value is null before accessing its properties

77
Q

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

A

B) Keeping conditions clear and avoiding excessive nesting

78
Q

The try-catch block is used to:

A) Perform arithmetic operations.
B) Handle runtime errors.
C) Define functions.
D) None of the above

A

B) Handle runtime errors.

79
Q

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

A

C) if (a == 0 || a / b > 2) {…}

80
Q

Which rule helps determine the order in which operations are performed?

A) Associativity
B) Precedence
C) Typing
D) None of the above

A

B) Precedence

81
Q

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

A) Initialization provides an initial value, while assignment updates the variable’s value.

82
Q

Expression trees are used to:

A) Parse expressions.
B) Optimize memory usage.
C) Visualize the order of evaluation.
D) None of the above

A

C) Visualize the order of evaluation.

83
Q

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

A) Error handling mechanisms, like try-catch blocks

84
Q

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

A

B) Use explicit conversions whenever possible

85
Q

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

A

B) All parts of the expression are evaluated before execution continues.