Testbudytestbudy
Back to Explore
💻

CISC 124

Queen's University

RI
by Rennie I
241flashcards
129practice tests
0clones
0views
April 7, 2026

Flashcards

(241)

Click a card to flip

Card 1

Why do non-trivial Java programs rely on objects rather than just primitive values?

Click to reveal answer

Answer

Objects can perform more operations than primitive values. They encapsulate both data and the methods/behaviors that operate on that data, enabling more complex and sophisticated program functionality.

Card 2

What are the three ways to create a Point2 object shown in the course materials, and what do they illustrate about object construction?

Click to reveal answer

Answer

1) new Point2() creates a default Point2 at (0.0, 0.0). 2) new Point2(1.0, 0.5) creates a Point2 with specified coordinates using a parameterized constructor. 3) new Point2(p2) creates a copy of an existing Point2 using a copy constructor. These illustrate constructor overloading and flexible object instantiation.

Card 3

How do you retrieve and modify the coordinates of a Point2 object, and what design pattern does this demonstrate?

Click to reveal answer

Answer

Use accessor methods like p.x() and p.y() to retrieve coordinates, and mutator methods like p.x(value), p.y(value), or p.set(x, y) to modify them. This demonstrates the getter/setter pattern, which provides controlled access to object state rather than direct field manipulation.

Card 4

How do Java arrays differ fundamentally from Python lists in terms of flexibility, and what are the three key constraints?

Click to reveal answer

Answer

Java arrays are far less flexible than Python lists. The three key constraints are: (1) no slicing of arrays, (2) no negative indexing (causes runtime error), and (3) element type must be specified at declaration. Arrays use zero-based indexing like Python, but lack the dynamic features that make Python lists powerful.

Card 5

Compare and contrast Python's for-in loop with Java's for-each loop when iterating over collections.

Click to reveal answer

Answer

Both iterate over elements directly without needing index management. Python: `for elem in t:` and Java: `for (double elem : arr)` achieve the same result. However, Java's for-each loop has the loop variable scoped to the loop body only. When you need the index of an element (not just the value), Java requires a traditional for-loop with an index counter, whereas Python uses `range(0, len(t))` or `enumerate()`.

Card 6

Why is accessing the last element of a Java array using `arr[arr.length - 1]` necessary, and what would happen if you tried `arr[-1]`?

Click to reveal answer

Answer

Java arrays are zero-indexed, so the last valid index is always (length - 1). Using `arr[-1]` causes a runtime error because Java does not support negative indexing like Python does. You must explicitly calculate the last valid index using the array's length property.

Card 7

Why is direct arithmetic comparison using == not appropriate for testing String equality in Java, and what method should be used instead?

Click to reveal answer

Answer

The == operator compares object references (memory addresses), not the actual character sequences. Two different String objects with identical content will return false with ==. Use the equals() method to compare the actual string values.

Card 8

Explain why the expression 'h' + 'a' + "ha" evaluates to "201ha" rather than "haha". What type promotion occurs?

Click to reveal answer

Answer

Operators with equal precedence evaluate left to right. First, 'h' + 'a' attempts char addition, but addition is not defined for char, so both operands are promoted to int (h=104, a=97), yielding 201. Then 201 + "ha" triggers string concatenation because one operand is a String, producing "201ha".

Card 9

What is the key difference between the substring(int start) and substring(int start, int end) methods in Java, and how do their indices work?

Click to reveal answer

Answer

substring(start) returns characters from index start to the end of the string. substring(start, end) returns characters from index start up to (but not including) index end. Both use zero-based indexing, and the end index is exclusive. For example, "abcdefg".substring(1) returns "bcdefg", and "abcdefg".substring(3, 4) returns "d".

Card 10

How does the compareTo() method work for String comparison, and what do its three possible return values indicate?

Click to reveal answer

Answer

compareTo() compares strings lexicographically. It returns a negative integer if the calling string precedes the argument lexicographically, zero if they are equal (equals() is true), and a positive integer if the calling string follows the argument. This enables ordering strings by alphabetical sequence.

Card 11

Why are String objects in Java considered immutable, and what actually happens when methods like toUpperCase() appear to modify a string?

Click to reveal answer

Answer

String objects are immutable—the sequence of characters can never be changed. Methods like toUpperCase() do not modify the original string; they create and return a new String object containing the transformed characters. The original string remains unchanged. This is why s.toUpperCase() without assignment has no effect.

Card 12

Why does Java require a main method to be inside a class, whereas Python can execute statements directly?

Click to reveal answer

Answer

Java is a compiled, statically-typed language designed around object-oriented principles where all code must belong to a class. Python is an interpreted, dynamically-typed language that executes top-to-bottom from the first line. Java's architecture requires a specific entry point (the main method) to define where execution begins within a class context.

Practice Tests

(129)
1

Objects and Basic Operations - Easy

Foundational understanding of object creation, method calls, and the Scanner class

8qeasy
2

Objects and State Management - Medium

Working with object state, method behavior, and understanding constructor overloading

9qmedium
3

Java Arrays and Loops - Fundamentals

Test basic understanding of Java array syntax, limitations, and iteration patterns compared to Python.

11qeasy
4

Java Arrays and Loops - Advanced Applications

Test application of array concepts to real problems, comparing Python and Java approaches, and understanding loop variable scope and index tracking.

11qmedium
5

String Fundamentals and Operations - Easy

Basic understanding of String class methods, char type, and string operations in Java.

11qeasy
6

String Operations and Type Conversions - Medium/Hard

Advanced String manipulation, char arithmetic, type conversions, and lexicographical ordering.

11qhard
7

Java Fundamentals and Python Comparison – Easy

Tests basic understanding of Java syntax, entry points, and differences from Python.

11qeasy
8

Java Fundamentals and Python Comparison – Medium

Tests deeper understanding of Java's object-oriented design, type system, and syntax rules.

11qmedium
9

If Statements, Scope, and Logical Operators—Easy

Introductory assessment covering if/else if/else structure, variable scope, and basic logical operators in Java.

11qeasy
10

If Statements, Scope, and Logical Operators—Medium/Hard

Advanced assessment covering scope edge cases, operator precedence, and the interplay between multiple return statements and compiler behavior.

11qhard
11

Java Collections Fundamentals (Medium Difficulty)

Tests understanding of ArrayList and HashSet creation, element types, common operations, and the Python-to-Java transition.

11qmedium
12

Java Collections and Type System (Hard Difficulty)

Focuses on edge cases, wrapper types, set operations, and conceptual depth around generics and collection choice.

11qhard
13

Javadoc, Contracts, and Invariants - Medium Difficulty

Test your understanding of documentation practices, method contracts (preconditions and postconditions), assertions, and class invariants.

11qmedium
14

Inheritance, Polymorphism, and Generics - Expert Difficulty

Advanced assessment of inheritance design, polymorphic type comparisons, enumerated types, and generic type parameters.

11qexpert
15

Arrays Fundamentals — Easy

Basic understanding of array declaration, purpose, and constraints.

8qeasy
16

Arrays Fundamentals — Medium

Conceptual reasoning about array constraints, type safety, and design implications.

8qmedium
17

Java Types, Variables, and Methods – Intermediate

Tests understanding of primitive vs. reference types, integer overflow, method declaration syntax, and Java semantics compared to Python.

11qmedium
18

Java Fundamentals – Expert Challenge

Advanced questions on primitive vs. reference types, method design, overflow behavior, and nuanced semantic differences between Java and Python.

11qhard
19

Array Indexing Fundamentals - Easy

Basic understanding of zero-based indexing, valid index ranges, and array element access.

11qeasy
20

Array Indexing and Bounds - Medium

Intermediate challenges involving array bounds, the relationship between array size and valid indices, and debugging out-of-bounds errors.

11qmedium
21

For Loop Fundamentals - Easy

Basic understanding of for loop structure, parts, and execution order.

9qeasy
22

For Loop Analysis and Application - Medium

Deeper understanding of for loop mechanics, scope, and practical applications like array traversal.

9qmedium
23

Array Loop Fundamentals - Practice Test 1

Tests understanding of array iteration patterns, loop bounds, and element access in array algorithms.

11qmedium
24

Array Loop Fundamentals - Practice Test 2

Advanced test focusing on loop boundary conditions, adjacent element patterns, and algorithm efficiency.

11qhard
25

ArrayList Fundamentals and Iteration

Test basic ArrayList operations, list manipulation, and iteration techniques.

11qeasy
26

ArrayList Iteration and List Manipulation

Test deeper understanding of iteration patterns, defensive programming, and practical ArrayList use cases.

11qhard
27

Arrays, Loops, and Control Flow - Foundational

Tests understanding of loop selection, array indexing, and break statement optimization.

11qmedium
28

Arrays, Loops, and Control Flow - Advanced

Tests optimization, edge cases, and synthesis across multiple concepts.

11qhard
29

Floating-Point Fundamentals – Practice Test 1

Covers IEEE 754 representation, error measurement, and basic arithmetic operations on floating-point numbers.

11qmedium
30

Floating-Point Arithmetic – Practice Test 2

Focuses on addition/subtraction mechanics, guard digits, and the consequences of repeated operations.

11qhard
31

Practice Test 1: Sets & Stack Fundamentals

Mixed-difficulty test covering set operations, set types, and stack implementation basics.

11qmedium
32

Practice Test 2: Advanced Set & Stack Concepts

Harder test focusing on algorithmic understanding, edge cases, and design trade-offs.

11qhard
33

Coin Flip Simulation: Foundational Concepts

Tests understanding of binomial distribution concepts and simulation mechanics at introductory level.

8qeasy
34

Coin Flip Simulation: Advanced Analysis

Tests interpretation of results, probability mechanics, and algorithmic reasoning at intermediate-to-advanced level.

8qhard
35

Object Structure and Behavior – Easy

Foundation-level assessment covering basic object terminology and concepts.

8qeasy
36

Object Structure and Behavior – Medium

Intermediate assessment focusing on composition, interaction, and design implications.

8qmedium
37

Java Generics and Recursion Fundamentals

Beginner-level assessment covering generic type constraints and basic recursion concepts.

11qeasy
38

Advanced Recursion and Generic Constraints

Intermediate-to-advanced assessment targeting deeper understanding of recursive decomposition and type system constraints.

11qmedium
39

Jump It Fundamentals – Easy

Basic comprehension of Jump It rules, valid moves, and simple scenarios.

7qeasy
40

Jump It Problem-Solving – Hard

Advanced reasoning about board solvability, cycle detection, and recursive decomposition.

8qhard
41

Recursive Sorting Fundamentals - Basic

Tests understanding of how minToFront works, the structure of selection sort, and basic recursion mechanics in list sorting.

11qeasy
42

Recursive Sorting Analysis - Advanced

Tests analysis of algorithm complexity, comparison of sorting approaches, and deeper understanding of recursion mechanics in selection sort.

11qhard
43

Jump It Problem: Fundamentals & Solution Design

Tests understanding of the Jump It problem structure, why greedy fails, and how to construct a recursive solution.

11qmedium
44

Jump It Problem: Deep Reasoning & Extensions

Advanced assessment focusing on why greedy fails, recursive proof of correctness, and problem variants.

11qhard
45

Board Solvability Recursion - Fundamentals

Tests understanding of the recursive backtracking algorithm structure, base cases, and state management in the isSolvable method.

11qmedium
46

Board Solvability Recursion - Deep Analysis

Advanced test focusing on edge cases, algorithm correctness, and the reasoning behind design choices in backtracking implementations.

11qhard
47

Object Lifecycle and Reference Semantics – Test 1

Medium-difficulty test covering object creation, lifecycle control, reference equality, and defensive copying.

11qmedium
48

Equals, HashCode, and Collections – Test 2

Hard-difficulty test covering equals contract, hashCode implementation, instanceof checks, and collection behavior.

11qhard
49

Linked List Fundamentals - Easy

Basic understanding of linked list structure and recursion

8qeasy
50

Linked List Recursion - Medium/Hard

Deeper analysis of recursive structure and algorithm design implications

8qhard
51

Nodes and Data Structures - Fundamentals

Foundation-level assessment of node concepts, their properties, and relationships to common data structures.

8qeasy
52

Nodes and Data Structures - Advanced Relationships

Intermediate to advanced assessment targeting conceptual connections between node structure, link semantics, and data structure properties.

8qmedium
53

Dice Odds Simulation – Fundamentals

Tests understanding of the simulation algorithm, list structure, and probability estimation.

11qeasy
54

Dice Odds Simulation – Advanced

Tests deeper conceptual understanding, coding implementation details, and statistical reasoning.

11qhard
55

Constructors Fundamentals — Easy

Basic understanding of constructor syntax, naming, and purpose.

8qeasy
56

Constructors Fundamentals — Medium

Deeper understanding of constructor mechanics, naming rules, and distinction from methods.

8qmedium
57

Set Operations Fundamentals - Practice Test 1

Tests understanding of set operations, particularly retainAll() and set intersection concepts

11qmedium
58

Set Operations Applied - Practice Test 2

Advanced application of set operations focusing on intersection logic and set algebra

11qhard
59

Set Operations Fundamentals - Practice Test 1

Foundation-level assessment covering set membership, removeAll() mechanics, and basic set algebra concepts.

11qeasy
60

Set Operations & Conceptual Mastery - Practice Test 2

Advanced assessment emphasizing the relationship between set methods and set algebra theory, with application scenarios.

11qmedium
61

Set-Based Duplicate Detection - Fundamentals

Test your understanding of how sets are used to identify and separate unique and duplicate accounts in a linear pass through data.

11qmedium
62

Set-Based Duplicate Detection - Advanced Applications

Deeper exploration of algorithm correctness, edge cases, and comparisons with alternative approaches.

11qhard
63

Constructors Fundamentals - Practice Test 1

Easy to medium difficulty assessment covering no-argument constructors, copy constructors, and parameterized constructors.

5qmedium
64

Constructors Fundamentals - Practice Test 2

Medium to hard difficulty assessment emphasizing the conceptual relationships between constructor types and object initialization.

5qhard
65

True/False - Constructors Fundamentals

Quick true/false checks on constructor concepts.

3qmedium
66

Short Answer - Constructor Design

Short-answer questions requiring explanation of constructor usage and design.

2qmedium
67

Essay - Constructor Strategy

Essay question on overall constructor design strategy.

1qhard
68

Set Operations and Behavior - Foundation

Basic understanding of set properties, the addAll() method, and how sets differ from other collections.

11qeasy
69

Set Operations and Collection Behavior - Advanced

Deeper analysis of set semantics, union operations, and collection design trade-offs.

11qmedium
70

Class Design & Documentation - Easy

Foundation-level assessment of class invariants, wrapper classes, and documentation practices.

11qeasy
71

Class Design & Documentation - Medium

Intermediate assessment requiring application of concepts to new scenarios and deeper reasoning.

11qmedium
72

Static Methods and String Conversion - Foundational

Tests understanding of static method invocation, String.valueOf(), and basic type conversion concepts.

5qeasy
73

Static Methods and Type Conversion - Advanced Application

Tests deeper understanding of when to use static methods, type conversion mechanisms, and API design choices.

8qmedium
74

Static Members and Utility Classes – Easy

Foundational concepts: accessing static members, public static final fields, and basic utility class design.

8qeasy
75

Static Members and Utility Classes – Hard

Advanced concepts: constructor delegation, static factory methods, and design patterns for avoiding constructor overloading.

8qhard
76

Static Fields Fundamentals - Easy

Basic understanding of static field concepts, memory organization, and when to use static vs. instance variables.

8qeasy
77

Static Fields in Context - Medium

Application of static field concepts to design decisions, memory efficiency, and distinguishing between static and instance data.

8qmedium
78

Scanner and Control Flow - Fundamentals

Basic understanding of Scanner input handling and loop control mechanisms.

11qeasy
79

Scanner and Control Flow - Advanced

Deeper analysis of input handling edge cases and program design patterns.

11qmedium
80

Method Preconditions – Fundamentals

Tests understanding of precondition definition, responsibility assignment, and documentation.

8qeasy
81

Method Preconditions – Application & Edge Cases

Tests ability to apply precondition concepts to real scenarios and understand enforcement tradeoffs.

8qmedium
82

Javadoc Fundamentals - Practice Test 1

Test on basic Javadoc structure, comment syntax, and documentation generation principles.

11qeasy
83

Javadoc Documentation Standards - Practice Test 2

Test on Javadoc best practices, proper use of block tags, and documentation strategies for different code elements.

11qmedium
84

Object Identity, Inheritance, and Class Invariants — Foundational

Tests understanding of why equals() must be overridden, how inheritance structures work, and the role of class invariants in substitutability.

8qmedium
85

equals(), Iterables, and Nested Classes — Advanced Application

Tests ability to apply concepts to novel scenarios, including custom equals() implementation, iterator design, and access modifier implications.

8qhard
86

Postconditions: Fundamentals & Implementation

Test understanding of postcondition concepts, checking mechanisms, and their practical application.

11qmedium
87

Postconditions: Advanced Scenarios

Test deeper understanding of postconditions in complex scenarios and edge cases.

11qhard
88

Static Factory Methods Fundamentals

Basic understanding of static factory methods, their purpose, and differences from constructors.

8qeasy
89

Static Factory Methods Advanced Applications

Deeper understanding of static factory method design patterns, immutability, and API design decisions.

8qmedium
90

Static Methods and Utility Classes — Foundational

Tests understanding of static features, utility class design, and basic access patterns.

11qeasy
91

Static Methods and Utility Classes — Advanced Application

Tests deeper understanding of static design patterns, access control, and practical utility class scenarios.

11qmedium
92

Enumerations: Fundamentals and Old-Style Problems

Easy-to-medium difficulty test covering the motivation for enums and problems with using primitives to represent enumeration values.

11qeasy
93

Enumerations: Advanced Problems and Best Practices

Medium-to-hard difficulty test covering deeper understanding of enumeration problems and design considerations.

11qmedium
94

Java Enums Fundamentals - Easy/Medium

Tests basic understanding of enum syntax, built-in methods, and field initialization.

11qmedium
95

Java Enums Advanced Concepts - Hard

Tests deep understanding of enum design principles, Comparable implementation, and field initialization patterns.

11qhard
96

Wrapper Classes, Generics, and Static Utilities

Test covering auto-boxing/unboxing, generic type declaration, utility class design, and static field semantics.

11qmedium
97

Advanced Static Features and Immutability

Expert-level test on compareTo contracts, mutable fields in constants, and advanced utility class patterns.

11qhard
98

Equals Implementation Fundamentals

Foundation-level test covering core concepts of equals contracts, state comparison, and field equality checking.

11qmedium
99

Advanced Equals and Type Checking

Advanced test covering instanceof type checking, transitivity pitfalls, and practical equals implementation strategies.

11qhard
100

Stack Fundamentals — Easy

Basic understanding of stack operations, terminology, and LIFO behavior.

10qeasy
101

Stack Applications & Behavior — Medium

Conceptual understanding of stack behavior, exceptions, and when stacks are applied.

10qmedium
102

Hash Tables and Comparable Practice Test 1

Focus on hashCode contracts, hash table performance, and Comparable interface fundamentals.

11qmedium
103

Hash Tables and Comparable Practice Test 2

Focus on hash function design, hashCode/equals contracts, Comparable consistency, and edge cases.

11qhard
104

Enums and Code Design Fundamentals

Test your understanding of when and why to use enums, and the readability improvements they provide.

11qeasy
105

Enum Design Principles and Application

Intermediate to advanced assessment of enum usage patterns, trade-offs, and when to use them vs. alternatives.

11qmedium
106

Stacks Fundamentals - Easy

Basic understanding of stack operations, LIFO principle, and real-world applications.

8qeasy
107

Stacks Implementation & Design - Medium

Deeper understanding of stack implementation choices, design patterns, and advanced applications.

8qmedium
108

Inheritance and Is-A Relationships - Foundational

Test your understanding of when inheritance is and isn't appropriate, and the reasoning behind the Circle-Ellipse problem.

5qmedium
109

Inheritance and Is-A Relationships - Advanced Application

Apply is-a principles to complex scenarios and evaluate design decisions.

6qhard
110

UML Class Diagrams and Relationships — Foundational Test

This test covers basic UML notation, class diagram components, and the conceptual distinctions between dependency, association, aggregation, and composition.

11qeasy
111

Composition, Defensive Copying, and Collections — Advanced Test

This test covers the mechanics of implementing composition with defensive copying, shallow vs. deep copies of collections, and the cost-benefit analysis of design choices.

11qhard
112

Stack-Based Recursion Conversion – Fundamental Concepts

Test your understanding of how stacks simulate recursive method calls and the basic conversion strategy.

11qmedium
113

Stack-Based Recursion Conversion – Advanced Application

Advanced questions testing synthesis, design decisions, and edge cases in converting recursive methods.

11qhard
114

Stack Implementation Fundamentals

Tests understanding of array-based and linked-list stack implementations, complexity analysis, and core operations.

11qmedium
115

Stack Operations and Design Patterns

Focuses on designing stack operations, iteration patterns, interface design, and comparing implementation strategies.

11qhard
116

Constructor Inheritance & Object Initialization

Tests understanding of superclass constructor calls, constructor chaining, and the object initialization chain.

11qmedium
117

Polymorphism & Type Systems

Tests understanding of subtype polymorphism, declared types vs. runtime types, and equals() implementation in inheritance hierarchies.

11qhard
118

Java Generics Fundamentals - Basic Comprehension

Test your understanding of generic class declaration, type parameters, and the motivation for using generics.

8qeasy
119

Java Generics Application - Medium Difficulty

Test your ability to apply generic concepts, understand parameterization, and work with multi-type generic classes.

8qmedium
120

Generics Fundamentals – Easy

Basic understanding of generics motivation and type safety concepts.

6qeasy
121

Generics and Type Safety – Medium

Deeper analysis of generics benefits, type safety mechanisms, and design trade-offs.

9qmedium
122

Inheritance for Code Reuse – Fundamentals (Medium)

Tests understanding of access modifiers, inheritance design, and the Liskov Substitution Principle in the context of the Counter example.

11qmedium
123

Inheritance for Code Reuse – Advanced (Hard)

Tests deeper reasoning about design trade-offs, substitutability, and real-world implications of visibility and contract decisions.

11qhard
124

Liskov Substitution & Dynamic Dispatch - Foundational

Tests understanding of how runtime types determine method behavior and why substitutability is critical for inheritance design.

5qmedium
125

Method Contracts & Invariants - Advanced Application

Deeper examination of how method contracts (parameters, return values, state changes) must be respected in subclass overrides.

6qhard
126

Java Generics Fundamentals - Easy

Basic questions on generic type constraints, array creation, and interface definition.

8qeasy
127

Java Generics - Medium/Hard

Deeper questions on generic constraints, type erasure implications, and implementation details.

8qhard
128

Generic Queues and Linked Lists — Foundation Test

Tests core understanding of queue structure, operations, implementations, and introductory linked-list concepts.

11qmedium
129

Advanced Queue and List Operations — Expert Test

Tests mastery of iterator design, array resizing, linked-list traversal, and generic methods applied to complex scenarios.

11qhard
💻

Start studying this set

Add this set to your library and use AI-powered flashcards, practice tests, and a personal study agent.