Docsity

STARTING OUT WITH JAVA FROM CONTROL STRUCTURES THROUGH DATA STRUCTURES FULL QUESTIONS AND, Exams of Object Oriented Programming

Toggle sidebar
bg1
STARTING OUT WITH JAVA FROM CONTROL STRUCTURES
THROUGH DATA STRUCTURES FULL QUESTIONS AND CORRECT
ANSWERS STUDY GUIDE
Question 1.
What is type checking?
Answer: The process of ensuring type consistency throughout a program.
Question 2.
What is type inference?
Answer: Automatically determining the types of expressions based on context.
Question 3.
What are type constructors?
Answer: Mechanisms for creating new types from existing ones (arrays, records,
pointers, unions, etc.).
Question 4.
What is a strongly typed language?
Answer: A language where all type errors must be detected before runtime.
Question 5.
What is a weakly typed language?
Answer: A language that permits operations that may result in type errors at
runtime.
Question 6.
What are simple types?
Answer: Types with no internal structure beyond basic values (int, char,
boolean, enums).
Question 7.
What is an enumerated type?
Answer: A type with explicitly listed named values.
Question 8.
What is a subrange type?
Answer: A type defined as a contiguous subset of another simple
pf3
pf4
pf5
pf8

Partial preview of the text

Download STARTING OUT WITH JAVA FROM CONTROL STRUCTURES THROUGH DATA STRUCTURES FULL QUESTIONS AND and more Exams Object Oriented Programming in PDF only on Docsity!

STARTING OUT WITH JAVA FROM CONTROL STRUCTURES

THROUGH DATA STRUCTURES FULL QUESTIONS AND CORRECT

ANSWERS STUDY GUIDE

Question 1.

What is type checking?

Answer: The process of ensuring type consistency throughout a program.

Question 2.

What is type inference?

Answer: Automatically determining the types of expressions based on context.

Question 3.

What are type constructors?

Answer: Mechanisms for creating new types from existing ones (arrays, records, pointers, unions, etc.).

Question 4.

What is a strongly typed language?

Answer: A language where all type errors must be detected before runtime.

Question 5.

What is a weakly typed language?

Answer: A language that permits operations that may result in type errors at runtime.

Question 6.

What are simple types?

Answer: Types with no internal structure beyond basic values (int, char, boolean, enums).

Question 7.

What is an enumerated type?

Answer: A type with explicitly listed named values.

Question 8.

What is a subrange type?

Answer: A type defined as a contiguous subset of another simple

type.

Question 9.

What is structural type equivalence?

Answer: Two types are equivalent if they have the same structure.

Question 10.

What is name type equivalence?

Answer: Two types are equivalent only if they use the same type name.

Question 11.

What is a Cartesian product type?

Answer: A type formed from ordered pairs (implemented as structs or records).

Question 12.

What is a union type?

Answer: A type allowing values from multiple alternative types.

Question 13.

What is a discriminated union?

Answer: A union with a tag identifying which value type is stored.

Question 14.

What is an undiscriminated union?

Answer: A union without tags, unsafe because the type isn't known.

Question 15.

What is a pointer type?

Answer: A type whose values are memory addresses referring to another type.

Question 16.

What is a reference type?

Answer: Like a pointer but not manipulated directly (e.g., Java objects).

Question 17.

What is a recursive type?

Answer: A type defined in terms of itself (linked lists, trees).

What is infix notation?

Answer: Operator between operands.

Question 28.

What is the sequence operator?

Answer: Allows multiple expressions to execute in order within another expression.

Question 29.

What is a guarded if?

Answer: An if with Boolean guards; only one true guard executes.

Question 30.

What is the dangling-else problem?

Answer: Ambiguity about which if a given else matches.

Question 31.

What rule fixes the dangling-else problem?

Answer: The closest-if rule: an else matches the nearest unmatched if.

Question 32.

What is a case/switch statement?

Answer: A multi-way branch based on a selector value.

Question 33.

What is a while loop?

Answer: Repeats while a condition is true.

Question 34.

What is a do-while loop?

Answer: Executes the loop body at least once before checking the condition.

Question 35.

What is a for loop?

Answer: Loop containing initialization, condition, and update expressions.

What is continue?

Answer: Skips the remaining loop body and starts the next iteration.

Question 37.

What is break?

Answer: Terminates the closest loop immediately.

Question 38.

What is the loop-and-a-half problem?

Answer: A loop that naturally needs an early exit in the middle; break solves it.

Question 39.

What is an exception?

Answer: An event indicating an error or unusual situation during execution.

Question 40.

What is raising an exception?

Answer: Triggering an exception event to interrupt normal control flow.

Question 41.

What is an exception handler?

Answer: Code that catches and processes an exception.

Question 42.

What is propagation of exceptions?

Answer: Searching up the call stack for a matching handler.

Question 43.

What is stack unwinding?

Answer: Exiting activation records while searching for a handler.

Question 44.

What is the termination model?

Answer: After handling an exception, execution continues after the handling block.

What is pass-by-value-result?

Answer: Copy in at call, copy out on return.

Question 55.

What is pass-by-name?

Answer: Argument expressions are re-evaluated each time the parameter is used.

Question 56.

What is a closure?

Answer: The combination of a function's code and its defining environment.

Question 57.

What is an activation record?

Answer: Memory allocated for one execution of a procedure (locals, return address, parameters).

Question 58.

What is a control link?

Answer: Points to the caller's activation record.

Question 59.

What is an access link?

Answer: Points to the lexical (defining) environment for nested procedures.

Question 60.

What is access chaining?

Answer: Following multiple access links to reach a nonlocal variable.

Question 61.

What is a static environment?

Answer: All memory allocated at load time; no recursion.

Question 62.

What is a stack-based environment?

Answer: Activation records pushed and popped as procedures execute and return.

Why is a stack insufficient for first-class functions?

Answer: Closures may refer to variables whose activation records have already been popped.

Question 64.

What is dynamic memory allocation?

Answer: Allocation of storage at runtime using a heap.

Question 65.

What is garbage collection?

Answer: Automatic reclamation of unused memory.

Question 66.

What is reference counting?

Answer: Each object tracks how many references point to it; freed when count hits zero.

Question 67.

What is the major drawback of reference counting?

Answer: Cannot reclaim cycles.

Question 68.

What is mark-and-sweep?

Answer: Marks reachable objects, then sweeps unmarked ones into the free list.

Question 69.

What is generational garbage collection?

Answer: Divides objects by age; young objects collected more frequently.