Oops Flashcards

1
Q

Encapsulation

A

Binding together the data and the functions that manipulates them.

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

Abstraction

A

Displaying only essential information and hiding the details
*Abstraction using classes
*Abstraction using Header Files (Math.h)

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

Polymorphism

A

Allows the user to invoke the derived class method through base class reference during runtime. Uses overloading and overriding methods

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

What is Java?

A

Java is a high-level object-oriented programming language known for its robustness, security, simplicity, and high performance.

Features include simplicity, object orientation, portability, platform independence, security, robustness, architecture neutrality, high performance, multithreading, and dynamic loading of classes.

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

What does JRE stand for?

A

Java Runtime Environment

It is part of the JDK and contains components to create and run Java programs.

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

What is the purpose of JDK?

A

Java Development Kit is used to develop Java applications and includes tools like compiler and debugger.

It also includes the JRE and JVM.

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

What is JVM?

A

Java Virtual Machine, which executes Java programs and is part of the JRE.

It acts as the space where Java programs run.

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

Define an object in Java.

A

An instance member of a Java class with its own identity, behavior, and state.

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

What is a class in Java?

A

A user-defined blueprint or prototype from which objects are created, representing a set of properties or methods common to objects of one type.

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

What is the root class from which every class extends?

A

The Object Class.

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

What are the primitive data types in Java?

A

The primitive data types are:
* byte
* long
* int
* double
* char
* float
* short
* boolean

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

Where are Strings stored in Java?

A

In a separate memory location in the heap known as the String Constant pool.

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

Explain the difference between stack and heap.

A

Stack is used for storing a collection of objects based on LIFO, while heap stores Java objects and can increase or decrease in size during runtime.

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

Are variable references stored on the stack or heap?

A

Local and static variable references are stored in the stack; Java objects are stored within the heap.

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

What is a stack frame?

A

Contains the state of one Java method invocation and is created when a function is called.

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

What are annotations in Java?

A

Used to provide supplementary information about a program without changing its actions, helping to associate metadata with program elements.

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

What is a POJO?

A

Plain Old Java Object, a Java object not bound by special restrictions, used for increasing readability and reusability.

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

What is a bean in Java?

A

A special POJO with restrictions, requiring access through getters and setters and encapsulating multiple objects.

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

Can you force garbage collection in Java?

A

No, but you can make an object eligible for garbage collection by severing its connection with variables.

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

Why are strings immutable in Java?

A

Because String objects are cached, and changes could affect multiple clients sharing the same string.

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

What is the difference between String, StringBuilder, and StringBuffer?

A

String is immutable; StringBuilder and StringBuffer are mutable. StringBuffer is thread-safe, while StringBuilder is not.

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

What are the variable scopes in Java?

A

The three types of variable scopes are:
* Local
* Instance
* Static

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

What are access modifiers in Java?

A

Keywords used to set the accessibility of classes, constructors, methods, and other members.

Types include private, public, protected, and default.

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

What are non-access modifiers in Java?

A

Keywords that notify the JVM about class behavior, methods, or variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the difference between static and final variables?
Static defines a class member independent of any object; final declares a constant variable that cannot be overridden.
26
What are the default values for all data types in Java?
Default values are: * char - or null * double - 0.0d * float - 0.0f * long - 0 * int - 0 * short - 0 * byte - 0 * boolean - false
27
What is a wrapper class in Java?
Provides a mechanism to convert primitive types into objects and vice versa. ## Footnote Wrapper classes include Boolean, Character, Byte, Short, Int, Long, Float, Double.
28
What is autoboxing?
The automatic conversion of primitive data types into their corresponding object wrapper class.
29
What is unboxing?
The automatic conversion of a wrapper type into its corresponding primitive data type.
30
Is Java pass-by-value or pass-by-reference?
Java is always pass-by-value.
31
What makes a class immutable?
Declaring the class with the final keyword.
32
If two objects are equal, do they have the same hashcode?
Yes, if two objects are equal, they must have the same hash code.
33
What data types are supported in switch statements?
Int, Byte, short, char.
34
List all non-access modifiers.
Non-access modifiers include: * static * final * abstract * synchronized * transient * volatile * strictfp
35
How to pass multiple values with a single parameter into a method?
By passing them as an array or collection of values.
36
What is a static block?
Used to initialize static data members.
37
What are static imports?
Allows public static members to be used in Java code without specifying the class.
38
What methods are available in the Object class?
Methods include: * clone() * equals() * finalize() * hashcode() * toString()
39
What is the difference between == and .equals()?
The == operator compares memory references, while equals() compares object values.
40
What is an enhanced for loop?
A simpler way to iterate through all elements of a collection or array.
41
What are the 3 usages of the 'super' keyword?
Usages include: * Referencing parent class variables * Invoking parent class methods * Accessing parent class constructors
42
What must be the first line of any constructor?
It must be a call to another constructor in the same class or a call to the superclass constructor.
43
What is constructor chaining?
Calling one constructor from another constructor of the same or parent class.
44
What are the 4 pillars of OOP?
The pillars are: * Inheritance * Encapsulation * Abstraction * Polymorphism
45
Explain the Single Responsibility Principle.
Each class should be responsible for a single part of the system.
46
What is the Open-Closed Principle?
Software components should be open for extension but closed for modification.
47
What is the Liskov Substitution Principle?
Objects of a superclass should be replaceable with objects of its subclasses without breaking the system.
48
What is the Interface Segregation Principle?
No client should be forced to depend on methods it does not use.
49
What is the Dependency Inversion Principle?
High-level modules should not depend on low-level modules; both should depend on abstractions.
50
What is the difference between an abstract class and an interface?
An abstract class can have both abstract and concrete methods, while interfaces can have abstract and concrete methods but are not hidden.
51
Can abstract methods have concrete methods?
Yes, abstract classes can have both concrete and abstract methods.
52
Can static methods access instance variables?
No, static methods cannot access instance variables.
53
What are the implicit modifiers for interface variables?
Implicitly public, static, and final.
54
What is the difference between method overloading and overriding?
Overloading is static and can occur within the same or between classes; overriding is dynamic and provides specific implementation during runtime.
55
Can you overload the main method?
No cannot override the main method because it is static. Static belongs to the class not the object. Private and default methods can’t be overridden. A protected method of a superclass can be overridden by using a subclass
56
What are covariant return types?
Allow more specific return types when overriding methods.
57
When do you use extends or implements keywords?
Use extends for abstract classes and implements for interfaces.
58
What are enumerations (enums)?
A data type that stores a list of constants.
59
When do you use extends or implements keywords?
Use extends for abstract classes or to extend behavior to another class. Implements are used with interfaces.
60
What are the implicit modifiers for interface variables / methods?
In Java 7, implicit modifiers are abstract and public. From Java 8, interfaces allow default and static.
61
What are collections in Java?
Framework that provides an architecture to store & manipulate a group of objects, achieving operations like sorting, searching, and insertion.
62
What are the interfaces in the Collections API?
Set, List, Queue, Deque.
63
What is the difference between a Set and a List?
Set is unordered and can’t have duplicates, while List is ordered and can contain duplicates.
64
What is the difference between an Array and an ArrayList?
Array has elements of similar data types with a set size; ArrayList provides dynamic arrays.
65
What is the difference between ArrayList and Vector?
ArrayList is not synchronized; Vector is synchronized and can use Enumeration.
66
What is the difference between TreeSet and HashSet?
TreeSet is sorted; HashSet is unsorted and faster. HashSet allows null objects; TreeSet does not.
67
What is the difference between HashTable and HashMap?
Hashtable is a legacy, thread-safe class that stores key-value pairs, while HashMap is a more modern, non-thread-safe implementation of the same concept.
68
Are Maps in the Collections API?
No, Maps store key-value pairs, while other interfaces store single values.
69
List several ways to iterate over a Collection.
* While loops * For loops * Enhanced for loops * forEach method * Using an iterator.
70
What is the purpose of the Iterable interface?
Root interface for all collection classes, allowing iteration in a forward direction.
71
What is an Iterator?
An object used to loop through collections like ArrayList and HashSet.
72
What is the difference between the Comparable and Comparator interfaces?
Comparable allows for a single compareTo() method; Comparator allows multiple ways of sorting.
73
What are generics?
Classes that accept one or more parameters, known as parameterized classes.
74
What is the diamond operator (<>)?
Used in generics to specify type parameters.
75
What is multithreading?
The process of executing multiple threads simultaneously.
76
In what ways can you create a thread?
* Extending a class from Thread class * Implementing a Runnable interface.
77
List the methods in the Thread class and Runnable interface.
* run() * start() * sleep() * join() * getName() * setName() * setPriority() * getPriority() * stop() * resume()
78
Explain the lifecycle of a thread.
* New * Runnable * Running * Non-Runnable/Blocked * Terminated.
79
What is deadlock?
A situation where two threads are waiting for each other to release locks.
80
What is the synchronized keyword?
Controls access of multiple threads to shared resources.
81
How do you serialize / deserialize an object in Java?
Implement java.io.Serializable interface and use ObjectOutputStream for serialization.
82
What is a Marker interface?
An empty interface with no fields or methods.
83
What are transient variables?
Indicates that a variable is not part of the persistent state of an object.
84
Difference between FileReader and BufferedReader?
FileReader reads from a disk drive; BufferedReader can read from any character stream.
85
Explain the try-with-resources syntax.
Allows declaring resources that will be closed after execution of a try block.
86
List some methods in the Scanner class.
* next() * nextLine() * nextBoolean() * nextInt() * nextShort() * nextDouble() * hasNextInt()
87
What is the difference between final, .finalize(), and finally?
Final restricts modification; finally allows code execution after try/catch; finalize cleans up before garbage collection.
88
Explain throw vs throws vs Throwable.
Throws are used in the method signature, while throw is used in the body. Throws indicate that any number of exceptions may be thrown, while throw is explicitly used for a single exception to be handled. It is useful for certain conditions or for custom exceptions.
89
Do you need a catch block?
No, you can have a finally block without a catch block.
90
What is the base class of all exceptions?
Throwable.
91
List some checked and unchecked exceptions.
* Checked: IOException, SQLException * Unchecked: ArithmeticException, NullPointerException.
92
Can you catch more than one exception in a single catch block?
Yes, using the pipe ‘|’ to separate exceptions.
93
What is inheritance
Inheritance: mechanism of consuming members of one class in another class by establishing parent & child relationship between classes.
94
What is abstraction
Abstraction: process of hiding implementation details & showing only functionality to user
95
What is polymorphism
Polymorphism: this allows the user to invoke the derived class method through base class reference during runtime. Uses overloading & overriding methods.
96
What is encapsulation
Encapsulation: mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit
97
What is the difference between method overloading and overriding? What are the rules for changing the method signature of overloaded methods?
Overloading- static-this can be performed either w/in a class as well as between parent & child class. Also defining multi or adding behavior to a method. Executed during compile time. Overriding-dynamic is used to provide specific implementation of a method that’s already provided by the parent super class. It is executed during runtime.
98
Explain the DAO design pattern
The Data Access Object (DAO) pattern is a structural pattern that allows us to isolate the application/business layer from the persistence layer (usually a relational database but could be any other persistence mechanism) using an abstract API.
99
What are the 4 parts of DAO
The Base Class (where java specific variables are stored/accessed/updated) The DAO Interface (which creates the base methods accessed in the code) The DAO Factory (connects the DAO to its implementation and establishes the connection to the database The DAO Implementation (makes calls to the database using the connection from the factory, based on functions in the DAO interface)
100
What is JDBC?
Java database connectivity is a standard Java API that allows Java applications to connect to and interact with databases.
101
What is JUnit?
JUnit is a unit testing framework for the Java programming language.
102
What is TDD?
Test-Driven Development is a software development approach in which test cases are developed to specify and validate what code will do.
103
What are the annotations in JUnit? Order of execution?
A special form of syntactic meta-data that can be added to Java source code for better code readability and structure. @BeforeClass-executed before first @Test method @Before -executed before all @Test method in the Junit test class @Test- Executed for all @Test methods @After- executed after all @Test methods @AfterClass-executed after all the @Test methods in the Junit test class
104
What is Maven?
It's a build automation tool used primarily for java projects. It is used to dynamically download java libraries and plug in from one or more repositories .
105
Where / when does Maven retrieve dependencies from? Where are they stored locally?
Maven automatically downloads all the dependency jars into the local repository. Defined dependencies will be loaded from remote repositories into gradle's local repository folder.
106
What is the POM and what is the pom.xml?
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project.
107
What does Pom.xml file contain
The pom.xml file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc. Maven reads the pom. xml file, then executes the goal.
108
Explain what SQL is. What are some SQL databases?
SQL stands for Structured Query Language and it allows the user to access and manipulate databases. Some SQL Databases: MySQL MariaDB Oracle PostgreSQL MSSQL
109
What are the 5 sublanguages of SQL? Which commands correspond to them?
DDL - Data Definition Language - CREATE, ALTER, DROP, TRUNCATE DML - Data Manipulation Language - INSERT, UPDATE, DELETE DQL - Data Query Language - SELECT DCL - Data Control Language - GRANT, REVOKE(Don’t think we did this?) TCL - Transaction Control Language - Start Transaction, COMMIT, ROLLBACK
110
What is the difference between DELETE, DROP, and TRUNCATE commands?
DELETE-we can either delete all rows at once or one by one, its slower than Truncate. Ex:delete from tabel_name or delete from table where column=name; DROP- can delete the whole structure(table) in one go, it remove the elements of the schema TRUNCATE-used to delete all rows of table in one go using the “truncate” command. But keeps the structure of the tabel. ex: TRUNCATE;
111
What are some SQL clauses you can use with SELECT statements?
WHERE - Also used in delete, update statements. Filters records before group by. HAVING - Filters records after group by GROUP BY - Groups records together based on column. Used with aggregate functions. ORDER BY -Sort table based on specified column.
112
Explain what the ORDER BY and GROUP BY clauses do
ORDER BY- A keyword that sorts the result in either ascending or descending order.Ascending by default. Use desc keyword to make it descend.USed after group by keyword GROUP BY- used to group rows that have the same value. USed with aggregate functions like AVG(), MAX(), COUNT(), MIN(), etc.Used before order by keyword
113
Explain the concept of relational integrity (related to primary/foreign key)
Used to ensure accuracy and consistency of data in the relational database. It has three key concepts: Relational Database:a type of database that stores information in the form of a 2-d table. Information integrity:the trustworthiness and dependability of information. Integrity constraints: sets of rules that can help maintain the quality of information that is acquired
114
Define the word “schema”
Logical collection of database objects.
115
What are some SQL data types?
CHAR VARCHAR DATE TIME DateTime INT
116
What is normalization? What are the levels?
Normalization is an organizational process used to reduce redundancy from a relation or set of relations. Streamline tables so entities aren’t present in multiple places, all requiring their own upkeep. Levels are 1NF - Every column only contains one value Before 1NF
117
What are the properties a transaction must follow?
Transaction must follow the ACID properties. A- Atomicity .Each statement in a transaction (to read, write, update or delete data) is treated as a single unit. Either the entire statement is executed, or none of it is executed. This property prevents data loss and corruption from occurring if, for example, if your streaming data source fails mid-stream. C-Consistency. Ensures that transactions only makes changes to tables in predefined predictable ways.Makes sure that errors in data won't create consequences for the integrity of the table I-Isolation-makes sure that multiple transactions do not interfere with one another. D- Durability. Make sure that changes in data made by transactions are saved.
118
What is the difference between joins and set operators?
Joins combine data into new columns. Unions combine data into new rows.
119
What are the types of joins? Explain the differences.
Inner join- an intersection between two tables, only the rows that both tables have in common are returned Left join-returns all records from left table and matching records from the right table. Right join- returns all records from the right table and matching records from the left tables. Self Join- a joins with itself Full outer join -
120
Explain the difference between UNION, UNION ALL, and INTERSECT?
Union - combines results from both tables. Union All - combines two or more results into a single set, including all duplicates. Intersect - takes the rows from both the result sets which are common in both.
121
What is the purpose of a view? What about an index?
Views are used to focus, simplify, and customize the perception each user has of the database. Index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes.
122
What is the difference between scalar and aggregate functions? Give examples of each
Aggregate-These functions are used to do operations from the values of the column and a single value is returned. AVG() COUNT() FIRST() LAST() MAX() MIN() SUM() Scalar-These functions are based on user input, these return a single value. UCASE() LCASE() MID() LEN() ROUND() NOW() FORMAT()
123
What is HTML
Hyper Text Markup Language. It provides a structure and content to a webpage
124
What is the HTML5 doctype declaration?
(probably the only line that matters, but still nice to know the rest) Document
125
What are the required tags for an HTML document?
HTML HEAD TITLE BODY
126
What’s the difference between an element and an attribute? List some global attributes.
HTML element holds the content. HTML attributes are used to describe the characteristics of an HTML element in detail.
127
What’s the difference between a class and id?
-side note, an id can be used like a class but, it is best practice to use it to identify a single element. An ID is only used to identify one single element in our HTML. A class can be used to identify more than one HTML element.
128
What’s the difference between a block and an inline element?
Inline elements occupy only sufficient width,dont start new lines, and don't have top/bottom margins. Block elements occupy full width of page, always start in a line, have top and bottom margins
129
What is a semantic tag? What about formatting tags/elements?
Semantic HTML tags provide information about the contents of those tags that goes beyond just how they look on a page. Formatting tags are used to make text bold, italicized, or underlined.
130
What is CSS? What are the different ways of styling an html file?
Cascading Style sheets. It can be added in 3 ways: inline-by using the style attribute in HTML elements, Internal-by using a