technical interview Flashcards

study for technical interview on the 12th at 12

1
Q

Encapsulation

A

is a concept of hiding data by wrapping up members into a single unit such as a Class. It provides security to data members by making the variable private, and then creating public getter/setter methods to access those variables.

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

Inheritance

A

the ability of creating a new class from an existing class. Inheritance is when an object acquires the property of another object. Inheritance allows a class (subclass) to acquire the properties and behavior of another class (super-class). It helps to reuse, customize and enhance the existing code.

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

Abstraction

A

concept that focuses on hiding the complexity of a system by presenting a simpler interface

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

Polymorphism

A

Stems from Inheritance. A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class. A subclass can have their own behavior and share some of its behavior from its parent class not the other way around. A parent class cannot have the behavior of its subclass.

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

Getters (Accessors)

A

These methods are used to retrieve or access the value of an object’s private variables. Instead of directly accessing the variable, you use a getter method which returns the value of the variable. This approach allows the encapsulation of the variable, as it can only be accessed through the method, and not directly, maintaining the integrity and security of the data.

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

Setters (Mutators)

A

Conversely, setter methods are used to set or update the value of an object’s private variables. Instead of modifying the variable directly, you pass the value you want to set to the setter method, which then assigns the value to the variable. This allows for data validation or additional logic to be executed before the variable is modified, ensuring that the object remains in a valid or consistent state.

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

Access Control

A

a mechanism that manages access to the classes, methods, and variables. It determines how and who can access different parts of your program, ensuring that sensitive information is hidden from users and prevents unauthorized access.

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

Access Modifiers

A
  • (public, private, protected): restricts visibility to class members; can be applied to class, methods, variables, and constructors; No modifier is also called default or package private.
    public: accessible from anywhere.
    protected: accessible within package and subclasses.
    no modifier: only accessible within package.
    private: only accessible within class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Class Binding

A

refers to the time at which a method or variable is associated with a class or object. Includes Static Binding (Early Binding) and Dynamic Binding (Late Binding).
Static Binding: Method execution determined at compile time, used for private, final, or static methods.
Dynamic Binding: Method execution determined at runtime, crucial for polymorphism.

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

Inheritance

A

the ability of creating a new class from an existing class. Inheritance is when an object acquires the property of another object. Inheritance allows a class (subclass) to acquire the properties and behavior of another class (super-class). It helps to reuse, customize and enhance the existing code.

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

Hierarchical inheritance

A

form of inheritance where one superclass is inherited by multiple subclasses. Imagine a tree with branches; at the top is the parent class, and branching out from it are several child classes. Each child class inherits from the same parent but is separate from its siblings. For example, a Vehicle class could be the parent, with Car, Bike, and Truck as child classes, each inheriting from Vehicle but not from each other.

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

Parent Class vs. Child Class

A

Parent Class (Superclass): The class whose features are inherited. It’s the “base” or “super” class.
Child Class (Subclass): The class that inherits from the parent class. It can add its own unique attributes and methods in addition to what it inherits.

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

Interfaces

A

contracts that define what a class can do without specifying how it does it. They’re like a checklist (e.g., a “to-do” list) for a class. Any class that implements an interface agrees to perform the tasks on the list. Uses the word ‘implements’ before listing the interfaces a class would use.

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

Abstract classes

A

classes that cannot be instantiated on their own and are designed to be extended. They can have both fully implemented methods and abstract methods (without bodies). Think of an abstract class as a template for other classes.

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

Abstract Methods

A

methods declared in an abstract class without an implementation. Subclasses are required to provide implementations for these methods. It’s like a rule saying, “If you choose to be this type of thing, you must be able to do these actions.”

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

Constructors

A

special methods used to initialize new objects. Think of it as setting up a new phone; a constructor sets up the initial state.

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

Default Constructors

A

constructors that take no arguments. If you don’t define any constructor in your class, most languages provide a default one that helps to create an object with default settings.

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

Polymorphism

A

Stems from Inheritance. A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class. A subclass can have their own behavior and share some of its behavior from its parent class not the other way around. A parent class cannot have the behavior of its subclass.

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

Method Overriding

A

when a subclass provides a specific implementation for a method that is already defined in its superclass. It’s like customizing the functionality of an inherited method.

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

Method Overloading

A

when multiple methods in the same class have the same name but different parameters. It’s like having different versions of a tool, each version doing a slightly different job based on what you need.

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

Runtime vs Compile-time

A

Runtime: Decisions made during the program’s execution, like dynamic binding.
Compile-time: Decisions made by the compiler before the program runs, like static binding.

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

Covariance vs Contravariance

A

Covariance and Contravariance deal with how the type of objects can be assigned in a hierarchy, affecting polymorphism and generic types. Covariance allows assignment from a subclass to a superclass, while contravariance is the opposite… How Java handles overridden methods.

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

Classes

A

blueprints for creating objects. Each object created from a class can have its own set of attributes and behaviors defined by the class.

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

Properties

A

characteristics of an object, like color or size. In programming, properties are often implemented as variables within a class.

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

Parameters

A

Parameters - variables that are used to pass data into methods and constructors.

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

Relational Model (RM) – (Tables, Columns, Rows)

A

Tables, Columns, Rows: The foundation of relational databases, where data is organized into tables (relations), columns (attributes), and rows (records).

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

1:1 (One-to-One)

A

Each row in Table A is linked to no more than one row in Table B, and vice versa. Example: Each person has only one passport, and each passport is assigned to only one person.

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

1:M (One-to-Many)

A

Each row in Table A can be linked to many rows in Table B, but each row in Table B is linked to only one row in Table A. Example: A mother can have many children, but each child has only one mother.

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

M:N (Many-to-Many)

A

Rows in Table A can be linked to many rows in Table B, and rows in Table B can also be linked to many rows in Table A. This relationship often requires a third table (junction table) to manage the relationships. Example: Students and courses where students can enroll in many courses, and each course can have many students enrolled.

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

Basic Queries

A

SELECT (FROM), WHERE, BETWEEN, LIKE, ORDER, JOIN

SELECT (FROM): Used to select data from a database.
WHERE: Filters records that fulfill a specified condition.
BETWEEN: Selects values within a given range.
LIKE: Searches for a specified pattern in a column.
ORDER: Sorts the result set in ascending or descending order.
JOIN: Combines rows from two or more tables, based on a related column between them.

31
Q

DML (Data Manipulation Language) Statements

A

(INSERT, UPDATE, DELETE)
INSERT: Adds new rows to a table.
UPDATE: Modifies existing records.
DELETE: Removes existing records.

32
Q

Primary Keys & Foreign Keys

A

Primary Keys: Uniquely identify each row in a table.
Foreign Keys: A key used to link two tables together.

33
Q

Normalization

A

Steps to organize database tables and their columns to reduce data redundancy and improve data integrity.
(1NF, 2NF, 3NF, BCNF)

34
Q

1NF (First Normal Form)

A

Ensures that the table has no repeating groups or arrays. Each column contains atomic (indivisible) values, and each column is unique.

35
Q

2NF (Second Normal Form)

A

Achieved when it is in 1NF and all non-key attributes are fully functional and dependent on the primary key.

36
Q

3NF (Third Normal Form)

A

3NF (Third Normal Form): Achieved when it is in 2NF and all the columns are only dependent on the primary key, not on other non-key attributes.

37
Q

BCNF (Boyce-Codd Normal Form)

A

A stronger version of 3NF. Achieved when, for every one of its dependencies X → Y, X is a superkey—a set of columns that uniquely identifies a row.

38
Q

DDL (Data Definition Language) Statements

A

(CREATE TABLE, ALTER TABLE, DROP TABLE, Constraints)
CREATE TABLE: Creates a new table.
ALTER TABLE: Modifies an existing table structure (e.g., adding or dropping columns).
DROP TABLE: Deletes an entire table.
Constraints: Rules applied to columns to ensure the integrity of the data (e.g., PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL).

39
Q

Inner Join

A

This join returns rows when there is at least one match in both tables. If there’s no match, the rows are not returned.

40
Q

Left Join (Left Outer Join)

A

This join returns all rows from the left table, and the matched rows from the right table. If there’s no match, the result set will still include all rows from the left table, with NULLs in columns from the right table. It’s like saying, “Give me everything from the left table, and if anything matches on the right, include that too.”

41
Q

Right Join (Right Outer Join)

A

This is the opposite of the Left Join. It returns all rows from the right table, and the matched rows from the left table. If there’s no match, you’ll still get all rows from the right table, with NULLs in columns from the left table. Using the previous example but wanting to list all departments and any assigned employees, even if some departments have no employees, a right join would suit this purpose.

42
Q

Full Outer Join

A

This join combines the results of both Left Join and Right Join. It returns all rows from both tables, with matches where available. If there’s no match, the missing side will contain NULLs. It’s like saying, “Give me everything from both tables, match them where you can, and show NULLs where you can’t.” If you wanted to list all employees and all departments, showing which employees are in which department and also showing employees without departments and departments without employees, a full outer join would be used.

43
Q

Stack

A

A collection that supports last-in, first-out (LIFO) semantics for adding and removing items.

44
Q

LinkedList

A

A collection of elements where each element points to the next and possibly the previous element, allowing for efficient insertion and removal.

45
Q

ArrayList

A

A resizable array, which can grow as needed. Supports random access of elements.

46
Q

Vector

A

Similar to ArrayList but synchronized, making it thread-safe at the cost of performance.

47
Q

Simple Queue

A

A collection that supports first-in, first-out (FIFO) semantics for adding and removing items.

48
Q

Circular Queue

A

A linear data structure that connects the last position back to the first position to make a circle, optimizing storage capacity.

49
Q

Priority Queue

A

Each element has a priority, and elements are removed based on their priority.

50
Q

Double Ended Queue (Deque)

A

A queue where elements can be added or removed from both the front and the back.

51
Q

HashMap

A

Stores key-value pairs in an unordered way. It allows storing null keys and values but doesn’t maintain any order.

52
Q

TreeMap

A

Stores key-value pairs in a sorted order. It cannot contain null keys but can contain multiple null values.

53
Q

LinkedHashMap

A

Similar to HashMap but maintains insertion order or access order.

54
Q

HashSet

A

Stores unique elements in no particular order. It allows for null elements.

55
Q

TreeSet

A

Stores unique elements in a sorted order. It does not allow for null elements.

56
Q

LinkedHashSet

A

Similar to HashSet but maintains insertion order.

57
Q

Equals Method

A

Determines if two objects are equal.

58
Q

HashCode

A

Returns an integer representation of an object’s memory address.

59
Q

If statement

A

Executes a block of code if a specified condition is true; otherwise, executes another block of code.
else -

60
Q

for loops

A

Repeats a block of code a certain number of times.

61
Q

while loops

A

Repeats a block of code as long as a specified condition is true.

62
Q

Mathematical Operations

A

Perform arithmetic calculations.

63
Q

Comparison Operations

A

Compare two values and return a boolean result.

64
Q

Increment Operators

A

Increase the value of a variable.

65
Q

Exception Handling

A

A mechanism to handle runtime errors, allowing the program to continue operation in a controlled manner. It’s typically implemented using try-catch blocks, where the try block contains code that might throw an exception, and the catch block contains code to handle the exception.

66
Q

Heap vs Stack

A

Heap: A memory area where objects are stored.
Stack: A memory area that stores method calls and local variables.

67
Q

Big-O Notation

A

Describes the performance or complexity of an algorithm.

68
Q

O(1)

A

Constant time - the execution time is constant and does not change with the size of the input data set.

69
Q

O(n)

A

Linear time - the execution time grows linearly with the size of the input data set.

70
Q

O(n^2)

A

Quadratic time - the execution time grows quadratically with the size of the input data set. It’s common with algorithms that involve nested iterations over the data set.

71
Q

O(log n)

A

Logarithmic time - the execution time grows logarithmically with the size of the input data set. It’s common in algorithms that break the data set in half every iteration, such as binary search.

72
Q

O(n log n):

A

the execution time grows linearithmically with the size of the input data set. Common in efficient sorting algorithms like mergesort and heapsort.

73
Q

Performance vs Scalability

A

Performance: How fast a system can perform under a given load.
Scalability: The ability of a system to handle an increasing amount of work.

74
Q

Agile vs Waterfall

A

Agile: A flexible and iterative approach to project management and software development.
Waterfall: A linear and sequential approach to project management and software development.