Docsity

STARTING OUT WITH JAVA: FROM CONTROL STRUCTURES THROUGH DATA STRUCTURES ACTUAL TEST PAPER, Exams of Java Programming

Toggle sidebar
bg1
STARTING OUT WITH JAVA: FROM CONTROL
STRUCTURES THROUGH DATA STRUCTURES
ACTUAL TEST PAPER QUESTIONS AND
SOLUTIONS GRADED A+
โ—‰ What are simple types?
Answer: Types with no internal structure beyond basic values (int,
char, boolean, enums).
โ—‰ What is an enumerated type?
Answer: A type with explicitly listed named values.
โ—‰ What is a subrange type?
Answer: A type defined as a contiguous subset of another simple
type.
โ—‰ What is structural type equivalence?
Answer: Two types are equivalent if they have the same structure.
โ—‰ What is name type equivalence?
Answer: Two types are equivalent only if they use the same type
name.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download STARTING OUT WITH JAVA: FROM CONTROL STRUCTURES THROUGH DATA STRUCTURES ACTUAL TEST PAPER and more Exams Java Programming in PDF only on Docsity!

STARTING OUT WITH JAVA: FROM CONTROL

STRUCTURES THROUGH DATA STRUCTURES

ACTUAL TEST PAPER QUESTIONS AND

SOLUTIONS GRADED A+

โ—‰ What are simple types? Answer: Types with no internal structure beyond basic values (int, char, boolean, enums). โ—‰ What is an enumerated type? Answer: A type with explicitly listed named values. โ—‰ What is a subrange type? Answer: A type defined as a contiguous subset of another simple type. โ—‰ What is structural type equivalence? Answer: Two types are equivalent if they have the same structure. โ—‰ What is name type equivalence? Answer: Two types are equivalent only if they use the same type name.

โ—‰ What is a Cartesian product type? Answer: A type formed from ordered pairs (implemented as structs or records). โ—‰ What is a union type? Answer: A type allowing values from multiple alternative types. โ—‰ What is a discriminated union? Answer: A union with a tag identifying which value type is stored. โ—‰ What is an undiscriminated union? Answer: A union without tags, unsafe because the type isn't known. โ—‰ What is a pointer type? Answer: A type whose values are memory addresses referring to another type. โ—‰ What is a reference type? Answer: Like a pointer but not manipulated directly (e.g., Java objects).

โ—‰ What is short-circuit evaluation? Answer: Evaluation of Boolean expressions stops once the result is known. โ—‰ What is prefix notation? Answer: Operator before operands. โ—‰ What is postfix notation? Answer: Operator after operands. โ—‰ What is infix notation? Answer: Operator between operands. โ—‰ What is the sequence operator? Answer: Allows multiple expressions to execute in order within another expression. โ—‰ What is a guarded if? Answer: An if with Boolean guards; only one true guard executes. โ—‰ What is the dangling-else problem? Answer: Ambiguity about which if a given else matches.

โ—‰ What rule fixes the dangling-else problem? Answer: The closest-if rule: an else matches the nearest unmatched if. โ—‰ What is a case/switch statement? Answer: A multi-way branch based on a selector value. โ—‰ What is a while loop? Answer: Repeats while a condition is true. โ—‰ What is a do-while loop? Answer: Executes the loop body at least once before checking the condition. โ—‰ 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.

Answer: Exiting activation records while searching for a handler. โ—‰ What is the termination model? Answer: After handling an exception, execution continues after the handling block. โ—‰ What is the resumption model? Answer: Execution restarts from where the exception occurred. โ—‰ What is a procedure? Answer: A collection of computations executed when called. โ—‰ What is a function? Answer: A procedure that returns a value. โ—‰ What is a procedure specification? Answer: Includes name, parameters, and return type. โ—‰ What is a procedure body? Answer: The block of statements the procedure executes. โ—‰ What are formal parameters?

Answer: The parameters listed in the procedure definition. โ—‰ What are actual parameters? Answer: The arguments supplied in the procedure call. โ—‰ What is pass-by-value? Answer: Argument values are copied; changes do not affect the caller. โ—‰ What is pass-by-reference? Answer: The caller's variable is passed; changes inside affect the caller. โ—‰ What is pass-by-value-result? Answer: Copy in at call, copy out on return. โ—‰ What is pass-by-name? Answer: Argument expressions are re-evaluated each time the parameter is used. โ—‰ What is a closure? Answer: The combination of a function's code and its defining environment.