Quality Assurance Engineer (Cognizant)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/58

flashcard set

Earn XP

Description and Tags

Week 1 and 2 QC

Last updated 7:57 AM on 6/20/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

59 Terms

1
New cards

Java supports automatic memory management through garbage collection.

True

2
New cards

In Java, why should you compare two strings for equal text with .equals(...)instead of == in application logic?

equals() compares values and == compares memory references.

3
New cards

What is garbage collection?

A process of reclaiming the runtime unused objects. It is performed for memory management.

4
New cards

In Python, what does the with statement give you when opening a file that manual open() / close()does not guarantee?

A with block uses a context manager so the file's __exit__ runs when leaving the block—even if an error occurs—so the file is closed reliably. Manual close() is easy to skip after an exception.

5
New cards

How is Java different from Python?

Java is statically typed, Python is dynamically typed

Java is compiled, Python is interpreted

Java requires explicit type declarations, Python infers types

Java enforces type checking at compile time, Python at runtime

Java has primitives, Python everything is an object

6
New cards

What is the difference between a JDK and a JRE for a developer who needs to compile Java?

The JDK includes development tools such as javac (the compiler) plus a JRE. A JRE alone can run bytecode but does not include javac, so it is not enough to compile new .java source.

7
New cards

What does the javac tool produce from .java source files?

javac compiles Java source into bytecode stored in .class files. The java launcher loads those classes into the JVM to execute them.

8
New cards

In Flask, how does a URL path (e.g. /items) connect to your Python code?

You register a route with decorators like @app.get("/items") or @app.post(...), which binds that URL to a view function. When a request matches, Flask calls that function and turns its return value into an HTTP response.

9
New cards

In a standard Maven layout, where does production Java source code live?

Production code lives under src/main/java. Tests go under src/test/java—Maven's convention over configuration layout.

10
New cards

What precondition does binary search on an array require that linear search does not?

Binary search requires the data to be ordered (typically a sorted array) so each step can discard half the remaining range. Linear search can run on unsorted data but is O(n) in the worst case.

11
New cards

What does the "S" in SOLID stand for, in one sentence?

Single Responsibility Principle: a class should have one cohesive reason to change—one primary job—so changes to unrelated concerns do not force edits in the same class.

12
New cards

A Java file begins with package com.example.qa.app;. Under a source root, which folder path must contain that file?

The path under the source root must mirror the package: com/example/qa/app/ (each segment is a folder). The package declaration and on-disk layout must match.

13
New cards

In Python, what is the effect of opening an existing text file with mode 'w'?

Mode 'w' opens for writing and truncates the file if it already exists (empties/overwrites from the start), or creates it if missing. Use 'a' to append without truncating.

14
New cards

In Java, how can two methods in the same class legally have the same name?

Method overloading: same method name but a different parameter list (number, types, or order). You cannot overload using return type alone—the compiler must disambiguate calls from arguments.

15
New cards

You call scanner.nextInt() and then scanner.nextLine(), but nextLine() returns an empty string before you can read the user's name. What is going wrong and how do you fix it?

nextInt() reads the number but often leaves the newline in the input buffer. The following nextLine() then consumes that empty line. Fix by calling an extra nextLine() to discard the remainder of the line after nextInt(), or read everything with nextLine() and Integer.parseInt with validation.

16
New cards

Your team's CSV pipeline must run on Windows and Linux and handle non-ASCII characters. What two practices from this week should you apply in Python when reading and writing those files?

Use encoding='utf-8' explicitly when opening text files so behavior is portable across platforms, and use with open(...) as f: so handles close correctly even when parsing throws—avoiding corrupted partial writes and leaked handles

17
New cards

You have a large sorted array of IDs and must look up whether a value exists many times. Another list is small and unsorted. Which search strategy fits each case, per this week's material?

For the large sorted array, binary search is appropriate—O(log n) per lookup. For the small unsorted list, linear search is fine; sorting just to binary search has overhead, and linear is simple O(n) for tiny n.

18
New cards

When implementing binary search with integer indices lo and hi, why do many implementations set mid = lo + (hi - lo) / 2 instead of (lo + hi) / 2?

For large arrays, lo + hi can overflow a 32-bit int, producing a negative midpoint and breaking the algorithm. lo + (hi - lo) / 2 computes the same midpoint using a rearrangement that stays within the representable range for typical bounds.

19
New cards

What is the difference between an interpreter and a compiler? Which does Python use? Which does Java use?

One is executed line by line, and the other is compiled all at once. Python is an interpreted language. In contrast, Java is a compiled language.

20
New cards

What is a REPL?

Read, Eval, Print, Loop (REPL) is a command line interpreter that allows code to be run line by line directly in the shell. This feature can be useful for debugging and testing small chunks of code quickly.

21
New cards

What is a compound statement?

Contains (group of) other statement; they affect or control the executable of those statements in some way. For example:

if score >= 90: print("Excellent job!") grade = "A"

22
New cards

What data types do we have by default in Python?

Int, float, str, and bool.

23
New cards

What is a namespace?

A container that maps names to objects. It is how Python keeps track of what variable/function/class name belongs to what and avoids naming conflicts.

24
New cards

What is the scope of a variable?

Where in your code a variable can be accessed.

25
New cards

What are functions?

A reusable block of code that performs a specific task.

26
New cards

What is a lambda function? What is the syntax for creating a lambda?

It's an anonymous function - a function without a def statement or a name. It is defined inline using the keyword lambda.

Example:

add_lambda = lambda a, b: a + b

is the same as:

def add(a, b):

return a + b

27
New cards

What is a list?

A List is an ordered collection of elements of a single data type in Java, but in Python, a list can hold mixed types.

28
New cards

What is a set?

Stores unique objects only. No duplicates, no guaranteed order, and it's mutable.

29
New cards

What is a tuple?

An immutable, ordered set of values of any type.

30
New cards

What is a dictionary?

A collection of key-value pairs.

31
New cards

How can we open a file? What are the different modes for opening a file?

We can open a file by using open(), which returns a file descriptor. The different modes are read, write, append, create, and read/write in binary mode.

32
New cards

What is a module? How do we import a module?

It's a single Python file. When you group multiple modules together in a folder, that folder becomes a package.

33
New cards

What are Regular Expressions? How do we use them?What is a datetime object?

It's a sequence of characters that defines a search pattern that we use to find, match, or manipulate strings. You can import it as re

34
New cards

What are some data collections we have at our disposal in the Collections module?

Lists, tuples, sets, Disctionaries

35
New cards

What is a class?

The blueprint

36
New cards

What is an object?

It's an entity with an identity having state and behavior within a well-defined boundary, and outside of that boundary, that object ceases to exist.

37
New cards

What are exceptions? How can we handle them?

Runtime errors that occur when something goes wrong with your program's logic. We can handle them with try/except blocks or try/except/finally. We can also create our own.

38
New cards

What is the purpose of the "if name == 'main':" statement in Python?

It prevents code from running automatically when the module is imported, only executing it when the file is run directly.

39
New cards

What is the difference between a local variable and a global variable in Python?

Local is inside the current function, while global is at the module level, so it's outside any function.

40
New cards

What is the purpose of the "map" function in Python?

It applies a function to every element in a sequence and returns the results.

Example: I want every element in this list to be an int soi use map(function, iterable)

41
New cards

What is the purpose of the "init" method in Python?

It's the constructor of a python class. It runs automatically every time you create a new object from that class. It's also a dunder method meaning you can override it to make it mean whatever want it to.

42
New cards

What is the purpose of the "self" keyword in Python?

Its the reference to the specific object being created

43
New cards

What is Git, and how does a distributed version control system differ from a centralized one?

Git is a distributed version control system (DVCS) that tracks changes to files, supports collaboration, and lets you roll back to prior states. In a centralized system, history lives primarily on one server; in a distributed system like Git, every clone carries a full copy of the repository and its history, so work can continue and be synchronized peer-to-peer via remotes (for example, GitHub) without a single central bottleneck.

44
New cards

Name Git's three main areas and describe what happens when you run git add and git commit.

The three areas are the working directory (your edited files), the staging area (index — what is prepared for the next commit), and the repository (committed history in .git). git add moves changes from the working directory into the staging area. git commit records the staged snapshot as a new commit in the repository history.

45
New cards

What is a Python virtual environment, and why is dependency isolation important?

A virtual environment is an isolated Python environment (its own interpreter location and installed packages) for a project. Isolation matters because installing packages globally forces one version per library for the whole machine; different projects often need different versions, and isolation prevents upgrades in one project from breaking another.

46
New cards

What does the LEGB rule describe in Python?

LEGB is the order Python uses to resolve a name to a variable: Local (inside the current function), Enclosing (outer nested functions), Global (module level), Built-in (Python's built-in names). Python searches L → E → G → B and uses the first match.

47
New cards

How do lists, tuples, and sets differ in terms of mutability, ordering, and duplicates?

Lists are mutable and ordered; they allow duplicates. Tuples are immutable and ordered; they allow duplicates. Sets are mutable (the set object can change), unordered, and store unique elements only.

48
New cards

What are the four pillars of object-oriented programming (OOP)?

The four pillars are encapsulation, inheritance, polymorphism, and abstraction.

49
New cards

What is encapsulation?

The bundling of data and behavior and controlling access

50
New cards

What is inheritance?

Deriving new types from existing ones

51
New cards

What is polymorphism?

The same interface or call can behave differently for different types

52
New cards

What is abstraction?

hiding complexity behind simpler interfaces

53
New cards

When calling a function, what rule applies to mixing positional and keyword arguments?

Positional arguments must come before keyword arguments. If you place a positional argument after a keyword argument, Python raises a SyntaxError. However, Keyword arguments can be passed in any order as long as all positional-required parameters are satisfied first.

54
New cards

What is the difference between using print() and the logging module for application output?

print() sends text to standard output with no built-in severity levels, timestamps, or flexible destinations. The logging module supports levels like debug, Info, warning, etc.that can route output to console, files, or other handlers, and is configurable at runtime.

55
New cards

What is a Python decorator, and what does @decorator_name above a function mean?

A decorator is a callable (usually a function) that takes a function and returns a wrapper that adds behavior before/after the original call without editing the original's body. The @decorator_name syntax is syntactic sugar for passing the function object to the decorator and rebinding the name to the returned wrapper.

56
New cards

What is an iterable versus an iterator in Python?

An iterable is an object with __iter__() that returns an iterator (e.g. list, str, dict). An iterator is an object with __next__() that returns the next value and raises StopIteration when exhausted. A for loop calls iter() then repeatedly next() until StopIteration.

57
New cards

Why does the curriculum discourage bare except: and broad except Exception: in production-style code?

A bare except: catches everything, including events you usually do not want to trap (for example KeyboardInterrupt and SystemExit), which makes programs hard to stop and hides real bugs. except Exception: is still very broad and can mask unexpected failures. Prefer catching specific exception typesyou can handle and recover from, so real defects surface during testing and debugging.

58
New cards

You need to increment a module-level counter from inside a function. What keyword is required, and what goes wrong if you omit it?

You must declare global counter (using the actual variable name) inside the function before assigning to it. Without global, Python treats counter += 1 as writing to a local variable that was never assigned a value in that scope, which leads to an UnboundLocalError when you try to read-update the global name.

59
New cards

How can two objects become uncollectable by reference counting alone, and what part of Python helps clean them up?

Reference counting frees an object when its count hits zero, but circular references (objects that refer to each other in a cycle) can keep counts above zero even when no outside references remain—so the cycle is not freed by reference counting alone. Python's gc module implements a generational garbage collectorthat periodically detects and collects such cycles (objects are grouped into generations 0-2 and collected with decreasing frequency).