Enterprise: Week 1 Flashcards

1
Q

What are environment variables?

A

Environment variables are values that are accessible in an entire working environment. In Unix, these values are set in the shell when it is started.

For example, your home directory is an environment variable called $HOME. If you wish to see the value of a particular environment variable, you can use the echo command like so: echo $HOME.

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

What are package managers?

A

In Unix, if you wish to install software, you generally use a package manager. There are many package managers available and we will talk about a few.

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

What are the basic linux commands?

A

The top-level directory is known as the root directory and it is the folder that contains all of the other folders on the drive partition you are currently accessing. In Unix, your root directory is represented by the / character. For example, if you wished to change directory to the root directory from anywhere on the partition, you would issue the following command: cd /

The . character represents the current directory. Furthermore, .. represents the parent directory, so if you wanted to copy everything from the current directory up to the directory immediately above it, you would issue the following command: cp -r . ..

In Unix, we also have a directory called the home directory. This directory is usually the one that our terminal starts in and it is where our personal files are generally stored. This directory is represented by the ~ character.

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

What are Flags Commands?

A

Flags are special arguments given to a command. There are two kinds of flags in Unix, short-hand or character flags, a single character (or group of characters), prefixed by a single dash -c, and full flags, the full name of the flag, prefixed by a double dash –flag.

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

What is the most important Linux Command?

A

man - The manual command will print to the terminal the manual for using a particular command. If you are unsure what flags or arguments a command takes, you simply type man command.

For example, if you wished to see the manual for the copy command, you would issue the command: man cp

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

What are the directory commands?

A

cd - The change directory command allows us to navigate to a different directory on the drive.

  • go to root directory: cd /
  • go to home directory: cd or cd ~
  • navigate one directory up: cd ..
  • navigate into the hi directory, which is inside the bye directory: cd ./bye/hi
  • change to the previous directory: cd -

ls - The list directory command allows us to see the contents of a particular directory. When given no arguments, it lists the contents of the current directory. The -a flag allows you to see hidden items in the directory.

  • list the contents of the current directory: ls
  • list the contents of the hi directory: ls hi or ls ./hi
  • list the contents of the directory including the “hidden” contents: ls -a

mkdir - The make directory command allows us to create a new directory. mkdir takes an argument representing the name of the directory you wish to create.
- create a directory named hi: mkdir hi

pwd - The print working directory command prints the full name of the directory you are currently working in. For example, if you were working in the home directory inside of the root directory the output of pwd might be /home.

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

What are the General Purpose Commands?

A

su - The substitute user command allows you to switch users. With no argument, this defaults to the root user, which has higher priveleges. This can be useful if you need to perform multiple commands with elevated priveleges but is generally considered to be bad practice in preference to sudo, for administrative logging purposes.

sudo - the sudo command allows you to run a particular command as the root user.

clear - the clear command usually prints a number of blank lines such that all previous commands are no longer on the screen. There is a shortcut for this command, ctrl-l

echo - the echo command will print a string or the result of a command to the console.

>

  • The > operator will redirect the output of a command to a file. The file will be created or overwritten if it already exists. ex. ls . > log.txt

> >

  • The&raquo_space; operator acts the same way as the > operator but appends output to the file instead of overwriting if it exists.

grep - the grep command prints any lines in a file or files that match a given pattern. By default, grep interprets the pattern as a basic regular expression.
- Print all lines in hello.txt that contain the word goodbye: grep goodbye hello.txt

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

What are the File Commands?

A

cat - the concatenate command prints the contents of a file to the console. cat hello.txt

head - the head command prints the first ten lines of a file to the console. head hello.txt

tail - the tail command prints the last ten lines of a file to the console. tail hello.txt

touch - the touch command allows you to modify the timestamp of a file. This command is usually used to create empty files, as an empty file is created if touch is given a file name that does not exist. touch hello.txt

cp - the copy command creates a copy of the specified file at the location specified. If the recursive glag is used, it will operate on directories.

  • copy a hello.txt to goodbye.txt: cp hello.txt goodby.txt
  • copy the hello directory to the goodbye directory: cp -r hello goodbye

mv - the move command will rename or move a file or entire directory with the recursive flag.

  • rename a hello.txt to goodbye.txt: mv hello.txt goodbye.txt
  • move hello.txt to the goodbye directory: mv hello.txt goodbye/.
  • rename the hello directory to goodbye: mv -r hello goodbye

rm - the remove command will delete a file. If you use the recursive flag, it can delete a directory. The force flag will cause the command to delete files without prompting the user if there are warnings. The command rm -rf . is extremely dangerous.

  • remove hello.txt: rm hello.txt
  • remove the hello directory: rm -r hello

wc - the word count command will print the number of words in a file. This command has several flags available

  • -c, –bytes - prints the byte count
  • -m, –chars - prints the character count
  • -l, –lines - prints the lines
  • -w, –words - prints the word count (default)

ln - the link command creates a link between files. This allows you to make a shortcut to a file in one location without copying it over.

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

What are the 3 File Permissions?

A

Owner permissions - What the owner of the file is allowed to do to the file.

Group permissions - What the group of users that the file belongs to is allowed to do to the file.

Other (world) permissions - What everyone else is allowed to do to the file.

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

How do you view permissions?

A

You can see the permissions of files in a directory by using the -l flag on the ls command to get it to print the “long listing format”

ls -l .

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

How do you change permissions?

A

You can change the permissions on a file using the chmod or change file mode bits command.

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

What is Git?

A

Git is a distributed version control system. This means that the entire codebase and history of a project is available on every developer’s computer as a local repository , which allows for easy branching and merging

This repository contains all of the information that the remote repository has, based on the last time that you synced those two together.

Even if you don’t have access to the remote repository, you can still view all of the changes that have been made, and contributers can maintain a copy of this record on their own machines.

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

What is GitHub?

A

GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code.

GitHub is a Git repository hosting service, but it adds many of its own features. While Git is a command line tool, GitHub provides a Web-based graphical interface. It also provides access control and several collaboration features, such as a wikis and basic task management tools for every project.

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

What is Git Branching?

A

Branching is a feature available in most modern version control systems. Instead of copying files from directory to directory, Git stores a branch as a reference to commit. The branch itself represents the HEAD of a series of commits.

The default branch name in Git is master, which commonly represents the official, working version of your project. As you start making commits, the master branch points to the last commit you made. Everytime you commit, the master branch pointer moves forward automatically. Think of a branch as a timeline of versions of a project as it progresses.

Branching is a strategy that allows developers to take a snapshot of the master branch and test a new feature without corrupting the project in production. If the tests are successful, that feature can be merged back to the master branch and pushed to production.

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

What is a JDK?

A

The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets.

It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development.

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

What is a JRE?

A

The Java Runtime Environment (JRE) is a set of software tools for development of Java applications. It combines the Java Virtual Machine (JVM), platform core classes and supporting libraries.

JRE is part of the Java Development Kit (JDK), but can be downloaded separately. JRE was originally developed by Sun Microsystems Inc., a wholly-owned subsidiary of Oracle Corporation.

Also known as Java runtime.

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

What is a JVM?

A

The Java Virtual Machine (JVM) is an abstraction layer between a Java application and the underlying platform. As the name implies, the JVM acts as a “virtual” machine or processor. To the bytecodes comprising the program, they are communicating with a physical machine; however, they are actually interacting with the JVM.

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

OOP: What is inheritance?

A

Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented programming system).

The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also.

Inheritance represents the IS-A relationship which is also known as a parent-child relationship.

On the basis of class, there can be three types of inheritance in java: single, multilevel and hierarchical.

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

OOP: What is Polymorphism?

A

Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.

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

OOP: What is encapsulation?

A

Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule which is mixed of several medicines.

We can create a fully encapsulated class in Java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it.

Advantages of Encapsulation:

By providing only a setter or getter method, you can make the class read-only or write-only. In other words, you can skip the getter or setter methods.

It provides you the control over the data. Suppose you want to set the value of id which should be greater than 100 only, you can write the logic inside the setter method. You can write the logic not to store the negative numbers in the setter methods.

It is a way to achieve data hiding in Java because other class will not be able to access the data through the private data members.

The encapsulate class is easy to test. So, it is better for unit testing.

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

What are the 4 types of java access modifiers?

A
  • private: within class
  • default: within class, package
  • protected: within class, package, by subclass
  • public: class, package, subclass, outside package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

OOP: What is abstraction?

A

Abstraction is a process of hiding the implementation details and showing only functionality to the user.

Another way, it shows only essential things to the user and hides the internal details, for example, sending SMS where you type the text and send the message. You don’t know the internal processing about the message delivery.

Abstraction lets you focus on what the object does instead of how it does it.

There are two ways to achieve abstraction in java

Abstract class (0 to 100%)
Interface (100%)

Abstract Class

A class which is declared as abstract is known as an abstract class. It can have abstract and non-abstract methods. It needs to be extended and its method implemented. It cannot be instantiated.

Some points to remember :

An abstract class must be declared with an abstract keyword.
It can have abstract and non-abstract methods.
It cannot be instantiated.
It can have constructors and static methods also.
It can have final methods which will force the subclass not to change the body of the method.

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

What is a class?

A

A class, in the context of Java, are templates that are used to create objects, and to define object data types and methods. Core properties include the data types and methods that may be used by the object

A class can also be defined as a blueprint from which you can create an individual object. Class doesn’t consume any space.

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

What is an object?

A

Any entity that has state and behavior is known as an object. For example a chair, pen, table, keyboard, bike, etc. It can be physical or logical.

An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other’s data or code. The only necessary thing is the type of message accepted and the type of response returned by the objects.

Example: A dog is an object because it has states like color, name, breed, etc. as well as behaviors like wagging the tail, barking, eating, etc.

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

What are the advantages of OOP over Procedural Oriented Programming?

A

OOPs makes development and maintenance easier whereas in a procedure-oriented programming language it is not easy to manage if code grows as project size increases.

OOPs provides data hiding whereas in a procedure-oriented programming language a global data can be accessed from anywhere.

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

What is the difference between an interface and an abstract class?

A

Conceptually, interfaces define behaviors and abstract classes are for concepts and inheritance.

You can implement multiple interfaces, but you can extend only one class.

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

What is an interface?

A

An interface acts as a contract for behaviors that a class can implement.

Interfaces have implicit modifiers on methods and variables.

  • Methods are ‘public’ and ‘abstract’
  • Variables are ‘public’, ‘static’, and ‘final’ To inherit interfaces, a class must implement them and they are REQUIRED to implement all methods, unless the class is abstract.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is Java’s Compilation process?

A

Compilation and Execution of a Java Program

Java, being a platform independent programming language, doesn’t work on one-step-compilation. Instead, it involves a two-step execution, first through an OS independent compiler; and second, in a virtual machine (JVM) which is custom-built for every operating system. The two principle stages are explained below:

Compilation:

First, the source ‘.java’ file is passed through the compiler, which then encodes the source code into a machine independent encoding, known as Bytecode. The content of each class contained in the source file is stored in a separate ‘.class’ file. While converting the source code into the bytecode, the compiler follows the following steps:

Parse: Reads a set of *.java source files and maps the resulting token sequence into AST (Abstract Syntax Tree)-Nodes.

Enter: Enters symbols for the definitions into the symbol table.

Process annotations: If Requested, processes annotations found in the specified compilation units.

Attribute: Attributes the Syntax trees. This step includes name resolution, type checking and constant folding.

Flow: Performs dataflow analysis on the trees from the previous step. This includes checks for assignments and reachability.

Desugar: Rewrites the AST and translates away some syntactic sugar.

Generate: Generates ‘.Class’ files.

Execution:

The class files generated by the compiler are independent of the machine or the OS, which allows them to be run on any system. To run, the main class file (the class that contains the method main) is passed to the JVM, and then goes through three main stages before the final machine code is executed. These stages are:

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

What are java’s primitive types?

A

The eight primitive data types in Java are:

  • boolean, the type whose values are either true or false
  • char, the character type whose values are 16-bit Unicode characters

The arithmetic types:

  • the integral types:
  • byte
  • short
  • int
  • long
  • the floating-point types:
  • float
  • double
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What are java literals?

A

Literals are values assigned to various variables, which differ in various forms. Whatever the input-form, the compiler will understand the code and the output will be as expected. We understood literals for Boolean, Integer, Character forms and implemented the understanding along with code. These literals are best applicable when we’re to pass a fixed value in code.

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

What are Java’s operators?

A

Java divides the operators into the following groups:

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Bitwise operators
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

What are Java’s arithmetic operators?

A

(+) Addition, Adds together two values
(-) Subtraction, Subtracts one value from another
(*) Multiplication, Multiplies two values
(/) Division, Divides one value by another
(%) Modulus, Returns the division remainder
(++) Increment, Increases the value of a variable by 1
(–) Decrement, Decreases the value of a variable by 1

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

What are java’s assignment operators?

A
=
\+=
-=
*=
/=
%=
&= example: x & 3
|= example: x | 3
^=
>>=
<<=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

What are java’s comparison operators?

A
==
!=
>
<
>=
<=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What are java’s logical operators?

A

&&
||
!

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

What are java’s reference data types?

A

Java provides two types of data types primitive and reference data type.

The primitive data types are predefined in Java that serves as a fundamental building block while the reference data type refers to where data is stored.

In Java, non-primitive data types are known as reference types. In other words, a variable of class type is called reference data type. It contains the address (or reference) of dynamically created objects. For example, if Demo is a class and we have created its object d, then the variable d is known as a reference type.

It refers to objects. It is not pre-defined. It is created by the programmer if required. The reference types hold the references of objects. All reference types are a subclass of type java.lang.Object. It provides access to the objects stored in the memory

Reference Type:
Class- It is a set of instructions. It describes the content of the object.
Array - It provides the fixed-size data structure that stores the elements of the same type.
Annotations - It provides a way to associate metadata with program elements.
Interface - It is implemented by Java classes.
Enumeration - It is a special kind of class that is type-safe. Each element inside the enum is an instance of that enum.

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

What are packages in Java?

A

Packages are a way of organizing classes, interfaces, and enums in a hierarchical manner. Packages follow a naming convention of lowercase characters separated by periods in the reverse way you would specify a web domain - thus, com.revature.mypackage instead of mypackage.revature.com.

Also, classes can be referenced anywhere in a program by their “fully qualified class name” - which is the package declaration followed by the class, in order to uniquely identify the class. In our example, the fully qualified class name is com.revature.mypackage.HelloWorld.

But typically we do not want to write out a verbose package and class name together. Instead, we can use an import statement after our package declaration to pull in other classes. We can then just use the class name without the package. By default, everything in the java.lang package is imported (which gives us the System class we used in the example). Other packages and classes must be imported by the programmer explicitly.

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

What is a Java Constant?

A

As the name suggests, a constant is an entity in programming that is immutable. In other words, the value that cannot be changed. In this section, we will learn about Java constant and how to declare a constant in Java.

In Java, to declare any variable as constant, we use static and final modifiers. It is also known as non-access modifiers. According to the Java naming convention the identifier name must be in capital letters.

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

What is the purpose for final and static modifiers?

A

Static and Final Modifiers:

  • The purpose to use the static modifier is to manage the memory.
  • It also allows the variable to be available without loading any instance of the class in which it is defined.
  • The final modifier represents that the value of the variable cannot be changed. It also makes the primitive data type immutable or unchangeable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

What are Access Modifiers?

A

Access modifiers are keywords which define the ability of other code to access the given entity. Modifiers can be placed on classes, interfaces, enums, and class members. The access modifiers are listed below:

Modifier Access Level:

  • public: Available anywhere
  • protected: Within the same package, and this class’ sub-classes
  • default: Within the same package
  • private: Only within the same class

The default access level requires additional clarification - this access level is “default” because there is no keyword to be used. This access level is also known as “package private”.

Using private modifiers on instance variables - along with public getter and setter methods - helps with encapsulation, which is one of the pillars of object-oriented programming.

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

What are Non-access modifiers?

A
Non-Access Modifiers:
Java also has non-access modifiers which can be placed on various class members:

static - denotes “class” scope, meaning the member resides on the class itself, not object instances.

  • static variables can be accessed through the class, e.g. MyClass.staticVariable
  • static methods can be called directly without needing an instance of the class, e.g. MyClass.someMethod()

final

  • when applied to a variable, it means the variable cannot be re-assigned
  • when applied to a class, it means the class cannot be extended
  • when applied to a method, it means the method cannot be overriden

abstract

  • when applied to a class, the class cannot be instantiated directly (instead, it should be inherited)
  • when applied to a method, only the method signature is defined, not the implementation. Also, the class where the method resides must also be abstract. Concrete subclasses must implement the abstract method.

synchronized - relevant to threads and preventing deadlock phenomena (discussed in a separate module)

transient - marks a variables as non-serializable, meaning it will not be persisted when written to a byte stream (discussed in another module)

  • volatile - marks a variable to never be cached thread-locally. Obscure, rarely-used keyword.
  • strictfp - restricts floating point calculations for portability. Obscure, rarely-used keyword.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What are the variable scopes?

A

When a variable is declared in a Java program, it is attached to a specific scope within the program, which determines where the variable resides. The different scopes of a variable in Java are:

  • Instance, or object, scope
  • Class, or static, scope
  • Method scope
  • Block scope

Instance scope means that the variable is attached to individual objects created from the class. When an instance-scoped variable is modified, it has no effect on other, distinct objects of the same class.

Class scoped variables reside on the class definition itself. This means that when objects update a class-scoped variable, the change is reflected across all instances of the class. Class scope is declared with the static keyword. Methods can also be declared as class scope. However, static methods cannot invoke instance methods or variables (think about it: which specific object would they reference?). Static methods and variables should be referenced through the class directly, not through an object. For example: MyClass.myStaticMethod() or MyClass.myStaticVariable.

Method scope is the scope of a variable declared within a method block, whether static or instance. Method-scoped variables are only available within the method they are declared; they do not exist after the method finishes execution (the stack frame is popped from the stack and removed from memory after execution).

Block scoped variables only exist within the specific control flow block, of which there are several in Java: for, while, and do-while loops, if/else-if/else blocks, switch cases, or even just regular blocks of code declared via curly braces ({}). After the block ends, variables declared within it are no longer available.

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

What are Arrays?

A

An array is a contiguous block of memory storing a group of sequentially stored elements of the same type. Arrays in Java are of a fixed size and cannot be resized after declaration. Arrays are declared with square brackets after the type of the array like so:

int[] myInts = new int[]{1, 2, 3, 4};
String languages[] = {“Java”, “JavaScript”, “SQL”};

Items in an array are referenced via their index in square bracket notation, which begins with 0 for the first element. Arrays also have a length property specifying the length of the array. This is helpful when iterating over arrays with a for loop:

String[] myArr = {“first”, “second”, “third”};
for (int i = 0; i < myArr.length; i++) {
System.out.println(myArr[i]);
}

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

What is a Varargs?

A

Instead of writing our main method the standard way, we can use an alternative notation:

public static void main(String… args) { }
Here we are using the varargs construct … which replaces the array notation. varargs stands for “variable arguments”, and allows us to set an argument to a method whose size is determined at runtime. Java will create an array under the hood to fit the arguments provided. You can only ever have 1 varargs parameter in a method, and it MUST be the last parameter defined (otherwise, how would the JVM know the difference between the last value in varargs and the next parameter of the method?). You can omit the vararg value when invoking the method and Java creates an array of size 0.

public class VarargsExample {
  public static void someMethod(int a, int... manyInts) {
    System.out.println("First argument: " + a);
	System.out.println("Next argument: ");
	for (int i = 0; i < manyInts.length; i++) {
	  System.out.println(manyInts[i]);
	}
  }
  public static void main(String[] args) {
    VarargsExample.someMethod(1, 3, 4, 5, 6);
	// First argument: 1
	// Next argument:
	// 3
	// 4
	// 5
	// 6
  }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

What does a forEach() Method do?

A

We can use the .forEach method of the Iterable interface, which accepts a lambda expression as its argument:

List names = new ArrayList<>();

names. add(“Alice”);
names. add(“Bob”);
names. add(“Charlie”);
names. forEach(str -> System.out.println(str));

This will print out the names just as if we had used a for loop. The lambda syntax could also be done with an explicit type declaration for the parameter, but the compiler can infer the type from the value used. For multiple parameters, parentheses are required around them. Also, curly braces are optional for single statements but required for multiple. Finally, the return keyword is also optional for a single expression because the value will be returned by default.

.forEach() method

The forEach() method actually accepts what is called a functional interface as its parameter (specifically a Consumer), which the lambda expression then implements at runtime. The forEach() method then loops through names and passes each element to the lambda expression to be “consumed”.

46
Q

What is time complexity?

A

Time complexity is a concept in computer science that deals with the quantification of the amount of time taken by a set of code or algorithm to process or run as a function of the amount of input.

In other words, time complexity is essentially efficiency, or how long a program function takes to process a given input.

47
Q

What is space complexity?

A

Space complexity in algorithm development is a metric for how much storage space the algorithm needs in relation to its inputs. This measurement is extremely useful in some kinds of programming evaluations as engineers, coders and other scientists look at how a particular algorithm works.

48
Q

What are asymptotic notations?

A

Asymptotic notations are used to represent the complexities of algorithms for asymptotic analysis. These notations are mathematical tools to represent the complexities. There are three notations that are commonly used.

49
Q

What is Big O Notation?

A

The Big O notation defines an upper bound of an algorithm, it bounds a function only from above. For example, consider the case of Insertion Sort. It takes linear time in best case and quadratic time in worst case. We can safely say that the time complexity of Insertion sort is O(n^2). Note that O(n^2) also covers linear time.

50
Q

How do you read from the console in Java?

A

Using Scanner class

51
Q

What is the Single-responsibility principle?

A

The single-responsibility principle (SRP) is a computer-programming principle that states that every class in a computer program should have responsibility over a single part of that program’s functionality, which it should encapsulate. All of that module, class or function’s services should be narrowly aligned with that responsibility.

52
Q

What is the DRY Principle?

A

The DRY principle is one of those long-standing ideas in computer science that is talked about with a bit of humor. DRY stands for “don’t repeat yourself,” and a corresponding WET principle stands for “write everything twice.” The DRY principle is often attributed to Andrew Hunt and David Thomas, whose book, the Pragmatic Programmer, came out in 2000.

53
Q

What is the Open-closed principle?

A

In object-oriented programming, the open–closed principle states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”;[1] that is, such an entity can allow its behaviour to be extended without modifying its source code.

The name open–closed principle has been used in two ways. Both ways use generalizations (for instance, inheritance or delegate functions) to resolve the apparent dilemma, but the goals, techniques, and results are different.

Open–closed principle is one of the five SOLID principles of object-oriented design.

54
Q

What is the Liskov Substitution Principle?

A

Substitutability is a principle in object-oriented programming stating that, in a computer program, if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., an object of type T may be substituted with any object of a subtype S) without altering any of the desirable properties of the program (correctness, task performed, etc.). More formally, the Liskov substitution principle (LSP) is a particular definition of a subtyping relation, called (strong) behavioral subtyping, that was initially introduced by Barbara Liskov in a 1987 conference keynote address titled Data abstraction and hierarchy. It is a semantic rather than merely syntactic relation, because it intends to guarantee semantic interoperability of types in a hierarchy, object types in particular.

55
Q

What is the Interface segregation principle?

A

In the field of software engineering, the interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use. ISP splits interfaces that are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them. Such shrunken interfaces are also called role interfaces. ISP is intended to keep a system decoupled and thus easier to refactor, change, and redeploy. ISP is one of the five SOLID principles of object-oriented design, similar to the High Cohesion Principle of GRASP.

56
Q

What is the Dependency Inversion Principle?

A

In object-oriented design, the dependency inversion principle is a specific form of loosely coupling software modules. When following this principle, the conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are reversed, thus rendering high-level modules independent of the low-level module implementation details. The principle states:[1]

High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g., interfaces).
Abstractions should not depend on details. Details (concrete implementations) should depend on abstractions.
By dictating that both high-level and low-level objects must depend on the same abstraction, this design principle inverts the way some people may think about object-oriented programming.[2]

The idea behind points A and B of this principle is that when designing the interaction between a high-level module and a low-level one, the interaction should be thought of as an abstract interaction between them. This not only has implications on the design of the high-level module, but also on the low-level one: the low-level one should be designed with the interaction in mind and it may be necessary to change its usage interface.

In many cases, thinking about the interaction in itself as an abstract concept allows the coupling of the components to be reduced without introducing additional coding patterns, allowing only a lighter and less implementation-dependent interaction schema.

When the discovered abstract interaction schema(s) between two modules is/are generic and generalization makes sense, this design principle also leads to the following dependency inversion coding pattern.

57
Q

What are the Design Patterns?

A

Design patterns are established general solutions to commonly occurring software development problems. They can be broadly categorized into:

  • Creational
  • Structural
  • Behavioral
58
Q

What is a Singleton Pattern?

A

A Singleton is a design pattern which allows the creation of an object in memory only once in an application and can be shared across multiple classes. It can be useful for services in an application, or other resources like a connection or thread pool.

To make a class into a Singleton, use:

  • private static variable of the class’ type
  • private constructor - to prevent arbitrary object creation
  • public static getInstance() method, which will either instantiate the object or return the instance in memory
59
Q

What is a Factory Pattern?

A

Factory is a design pattern which creates objects in which the precise type may not be known until runtime. To make a factory, use:

  • Abstract data type
  • Classes that inherit the abstract data type (the objects whose instantiation details may not be known until runtime)
  • Static method that returns a concrete instance, whose return type is the abstract data type in (1)
60
Q

What is a Dependency Injection?

A

Another important design pattern which is widely used in frameworks across many languages is dependency injection (DI), which is one form of a broader concept called inversion of control (IOC). DI means that the dependencies of a class or object are declared by the class and then injected from its context instead of instantiating and relying directly on it.

There are several ways to inject dependencies:

  • Constructor injection
  • Setter injection
  • Interface injection
61
Q

What are the Benefits of Dependency Injection?

A

Dependency injection has many benefits, including:

  • decoupling of code
  • independent development - coding to interfaces allows concurrent development
  • abstraction - no need to rely on concrete implementation
  • easier to test - allows creation of stubs and mocks
  • configuration can be externalized
62
Q

What are java exceptions?

A

When an exceptional condition occurs in the course of a Java program, a special class called an Exception can be thrown, which indicates that something went wrong during the execution of the program. If the exception is not handled anywhere in the program, it will propagate up through the call stack until it is handled by the JVM which then terminates the program.

63
Q

What is done with risky code?

A

When risky code is written that has the possibility of throwing an exception, it can be dealt with in one of two ways:

  • Handling means that the risky code is placed inside a try/catch block
  • Declaring means that the type of exception to be thrown is listed in the method signature with the throws keyword. This is also called “ducking” the exception - you let the code which calls the method deal with it.
64
Q

How to use Try-with-resources?

A

When using try/catch blocks, often times some object used in the code is a resource that should be closed after it is no longer needed to prevent memory leaks - for example a FileReader, InputStream, or a JDBC Connection object. With Java 7, we can use a try-with-resources block which will automatically close the resource for us:

OLD WAY:

try {
  InputStream is = new FileInputStream("./some/file.ext");
  String s = is.read();
} catch(IOException e) {
} finally {
  is.close();
}

NEW WAY:

try(InputStream is = new FileInputStream("./some/file.ext")) {
  String s = is.read();
} catch(IOException e) {}

Whatever is placed within the parenthesis of the try statement will be closed automatically - thus, we don’t need to explicitly call it within our finally block above. This new format requires the object in the try statement to implement the AutoCloseable interface.

65
Q

What is a Multi-catch block?

A

Try/catch/finally Blocks
In order to handle exceptions that could be thrown in our application, a try/catch block can be used. The try block encloses the code that may throw an exception, and the catch block defines an exception to catch and then runs the code inside only if that type of exception is thrown. We can optionally include a finally block which will run whether an exception is thrown or not. A simple example is shown below:

try {
object.someRiskyMethodCall();
} catch(Exception e) {
System.out.println(“phew! that was close!”);
} finally {
System.out.println(“I’ll run whether there was a problem or not!”);
}

66
Q

What are the rules for Try/catch/finally and Multi-catch Blocks?

A

Catch and finally blocks have several different rules which must be followed:

  • Multiple catch blocks are allowed. More specific exceptions must come before more general exception types.
  • Multi-catch blocks (catching more than one exception in a given block) are allowed, exception types are separated by ||
  • The finally block is optional
  • A try/finally block only IS allowed, but a try block by itself is not
  • A finally block will always execute, unless of course System.exit() is called.
67
Q

What are Checked vs Unchecked Exceptions?

A

The Exception class and all of its subclasses, except for RuntimeException, are known as “checked exceptions”. These represent occasions where it is reasonable to anticipate an unexpected condition, like a file not existing when attempting to write to it (which would result in a FileNotFoundException).

** Checked exceptions are required to be handled or declared by the programmer - otherwise, the code will not compile.

RuntimeException is a special type of exception - it, and all of its subclasses - are known as “unchecked exceptions”. An unchecked exception is an exception that is not required to be handled or declared like checked exceptions are. Some examples include:

  • ArithmeticException for illegal math operations
  • IndexOutOfBoundsException for if you reference an index that is greater than the length of an array
  • NullPointerException for if you attempt to perform an operation on a reference variable that points to a null value
68
Q

What is the Exception Class Hierarchy?

A

Error -> Throwable

ClassNotFound -> Exception -> Throwable

CloneNotSupported -> Exception -> Throwable

(EOFException, FileNotFound Exception, MalformedURL Exception, UnknownHost Exception) -> IOException -> Exception -> Throwable

(NullPointer, NoSuchElement, IndexOutOfBounds, IllegalState, IllegalArgument, ClassCast, Arithmetic) -> Runtime Exception -> Exception -> Throwable

The exception class hierarchy starts with the Throwable class which inherits from Object. Any object which is a Throwable can be “thrown” in a program by the JVM or by the programmer using the throws keyword. The Exception and Error classes both extend Throwable. An Error represents something that went so horribly wrong with your application that you should not attempt to recover from. Some examples of errors are:

  • ExceptionInInitializerError
  • OutOfMemoryError
  • StackOverflowError

Exception is a general exception class which provides an abstraction for all exceptions. There are many subclasses of Exception, as shown above.

69
Q

How do you create a Custom Exception?

A

A programmer can create custom exceptions in Java by extending any exception class. If you extend RuntimeException, however, you will be creating an unchecked exception. This is a good idea if you do not want other code to have to handle your exception being thrown. If you do always want to require your exception to be handled, then create a checked exception by extending any existing one, or the Exception class itself.

public class MyCheckedException extends Exception {}
public class MyUncheckedException extends RuntimeException {}

public class ExceptionThrower {

  public static void main(String[] args) {
    try {
	  throw new MyCheckedException("uh oh");
	} catch(MyCheckedException e) {} // we're just ignoring it here
    if ( 100 > 1) {
	  throw new MyUncheckedException("you're not required to handle me!");
	}
  }
  public static void declareChecked() throws MyCheckedException {
    throw new MyCheckedException("this one is declared!");
  }
}
70
Q

What is the String class?

A

Strings are not primitives - they are immutable, constant objects derived from the String class. To be immutable means that the state or value of the object cannot be altered once created - this is accomplished by having internal, private and final fields and not implementing any “setter” methods which would alter the state of those fields.

Because Strings are immutable, all of the methods in the String class return a new String - the original is not modified. For example:

String str1 = “my string”;
str1.concat(“ is the best!”);
System.out.println(str1);

will print out my string. Why? Because the .concat() method returns a completely different string which we are not assigning to any variable, and the original object is not changed (it is immutable). Thus, str1 still refers to the String “my string”. In order to make the code print “my string is the best!”, we would need to change line 2: str1 = str1.concat(“ is the best!”); which re-assigns the reference variable str1 to the new String returned from the method (the original String hasn’t changed, however).

The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.
Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
 String str = "abc";

is equivalent to:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
71
Q

What is a String Pool?

A

When Strings are created they are placed in a special location within the heap called the String Pool. When String literals are created, if there is an existing String that matches in the String Pool, the reference variable will point to the existing value. Duplicates will not exist in the String Pool. This is important because Strings take up a lot of memory. Being able to reuse the same value throughout your application is advantageous.

One way to circumvent the above process is to use the new keyword along with the String constructor, which will explicitly create a new String object in memory, even if one already exists in the String Pool.

72
Q

What is File I/O

A

“I/O” refers to the nature of how data is accessed, either by reading it from a resource (input) or writing it to a resource (output). In Java, File I/O objects fall into one of two categories:

  • Streams are for reading or writing bytes
  • Reader/Writer are for reading or writing characters

Some Common File I/O classes are

  • FileInputStream - reads raw bytes from a file
  • FileOutputStream - writes raw bytes to a file
  • FileReader - reads characters from a file
  • FileWriter - writes characters to a file
  • BufferedReader - reads a file line by line, needs an instance of a FileReader with a path to the resource to be read in the constructor
  • BufferedWriter - writes to a file line by line, needs an instance of a FileWriter with a path to the destination file in the constructor
  • Scanner - can read from an InputStream, useful methods for character reading

Character files are read line by line, either until a carriage return (\r) or a newline (\n), depending on your operating system. When using I/O classes to read and write, you should always close your resources with the .close() method. This prevents exceptions from being thrown later, memory leaks, and system overutilization of unused resources.

73
Q

How do you read from the console using Scanner?

A

The Scanner class can be used to read user input from the command line:

Scanner sc = new Scanner(System.in);
while (true) {
  String input = sc.readLine();
  System.out.println("Your input: " + input);
}

When the code above is run, the program acts to “echo” back any input given from stdin.

74
Q

What is Serialization?

A

Serialization is the process of writing the state of an object to a byte stream; the reverse is called deserialization. In order for an object to be serialized, it must implement the Serializable interface.

75
Q

What is the Marker Interfaces?

A

Serializable is a marker interface, which is an interface with no methods. The point of such an interface is to provide metadata to the compiler - in this case, it tells the compiler that this class can be serialized.

76
Q

How do you Serialize/DeSerialize an Object?

A

To serialize an Object, you need a FileOutputStream instance inside the constructor of an ObjectOutputStream, passing in the file path of where you want the Object to be serialized

  • Call the ObjectOutputStream.writeObject(yourObject) method

To deserialize an Object, you need a FileInputStream instance inside the constructor of an ObjectInputStream, passing in the file path of where the serialized object is

  • Call the ObjectInputStream.readObject() method, casting it to a bean of your type
77
Q

What is Method Overloading and Method Overriding?

A

Method Overloading

  • If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.
  • If we have to perform only one operation, having same name of the methods increases the readability of the program.
  • Suppose you have to perform addition of the given numbers but there can be any number of arguments, if you write the method such as a(int,int) for two parameters, and b(int,int,int) for three parameters then it may be difficult for you as well as other programmers to understand the behavior of the method because its name differs.

Method Overriding

  • If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java.
  • In other words, If a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding.

Usage and Rules for Method Overriding

Usage :

  • Method overriding is used to provide the specific implementation of a method which is already provided by its superclass.
  • Method overriding is used for runtime polymorphism

Rules :

  • The method must have the same name as in the parent class
  • The method must have the same parameter as in the parent class.
  • There must be an IS-A relationship (inheritance).
78
Q

What are java covariant types?

A

The covariant return type specifies that the return type may vary in the same direction as the subclass.

Before Java5, it was not possible to override any method by changing the return type. But now, since Java5, it is possible to override method by changing the return type if subclass overrides any method whose return type is Non-Primitive but it changes its return type to subclass type.

Java doesn’t allow the return type based overloading but JVM always allows return type based overloading. JVM uses full signature of a method for lookup/resolution. Full signature means it includes return type in addition to argument types. i.e., a class can have two or more methods differing only by return type. javac uses this fact to implement covariant return types.

79
Q

What are java functional interfaces?

A

Functional interfaces are interfaces that have only one abstract method. This method is what lambdas are implementing when they are declared - the parameter types and return types of the lambda must match the functional interface method declaration. The Java 8 JDK comes with many built-in functional interfaces, listed in the Javadocs link above.

We can also use functional interfaces as types to which we can assign lambda functions, like so:

interface MyFunctionalInt {
  int doMath(int number);
}
public class Execute {
  public static void main(String[] args) {
    MyFunctionalInt doubleIt = n -> n * 2;
	MyFunctionalInt subtractIt = n -> n - 2;
	int result1 = doubleIt.doMath(2);
	int result2 = subtractIt.doMath(8);
	System.out.println(result1); // 4
	System.out.println(result2); // 6
  }
}

An Interface that contains exactly one abstract method is known as functional interface. It can have any number of default, static methods but can contain only one abstract method. It can also declare methods of object class.

Functional Interface is also known as Single Abstract Method Interfaces or SAM Interfaces. It is a new feature in Java, which helps to achieve functional programming approach.

BiConsumer: It represents an operation that accepts two input arguments and returns no result.
Consumer: It represents an operation that accepts a single argument and returns no result.
Function: It represents a function that accepts one argument and returns a result.
Predicate: It represents a predicate (boolean-valued function) of one argument.
BiFunction: It represents a function that accepts two arguments and returns a a result.
BinaryOperator: It represents an operation upon two operands of the same data type. It returns a result of the same type as the operands.
BiPredicate: It represents a predicate (boolean-valued function) of two arguments.
BooleanSupplier: It represents a supplier of boolean-valued results.
DoubleBinaryOperator: It represents an operation upon two double type operands and returns a double type value.
DoubleConsumer: It represents an operation that accepts a single double type argument and returns no result.
DoubleFunction: It represents a function that accepts a double type argument and produces a result.
DoublePredicate: It represents a predicate (boolean-valued function) of one double type argument.
DoubleSupplier: It represents a supplier of double type results.
DoubleToIntFunction: It represents a function that accepts a double type argument and produces an int type result.
DoubleToLongFunction: It represents a function that accepts a double type argument and produces a long type result.
DoubleUnaryOperator: It represents an operation on a single double type operand that produces a double type result.
IntBinaryOperator: It represents an operation upon two int type operands and returns an int type result.
IntConsumer: It represents an operation that accepts a single integer argument and returns no result.
IntFunction It represents a function that accepts an integer argument and returns a result.
IntPredicate It represents a predicate (boolean-valued function) of one integer argument.
IntSupplier It represents a supplier of integer type.
IntToDoubleFunction It represents a function that accepts an integer argument and returns a double.
IntToLongFunction It represents a function that accepts an integer argument and returns a long.
IntUnaryOperator It represents an operation on a single integer operand that produces an integer result.
LongBinaryOperator It represents an operation upon two long type operands and returns a long type result.
LongConsumer It represents an operation that accepts a single long type argument and returns no result.
LongFunction It represents a function that accepts a long type argument and returns a result.
LongPredicate It represents a predicate (boolean-valued function) of one long type argument.
LongSupplier It represents a supplier of long type results.
LongToDoubleFunction It represents a function that accepts a long type argument and returns a result of double type.
LongToIntFunction It represents a function that accepts a long type argument and returns an integer result.
LongUnaryOperator It represents an operation on a single long type operand that returns a long type result.
ObjDoubleConsumer It represents an operation that accepts an object and a double argument, and returns no result.
ObjIntConsumer It represents an operation that accepts an object and an integer argument. It does not return result.
ObjLongConsumer It represents an operation that accepts an object and a long argument, it returns no result.
Supplier It represents a supplier of results.
ToDoubleBiFunction It represents a function that accepts two arguments and produces a double type result.
ToDoubleFunction It represents a function that returns a double type result.
ToIntBiFunction It represents a function that accepts two arguments and returns an integer.
ToIntFunction It represents a function that returns an integer.
ToLongBiFunction It represents a function that accepts two arguments and returns a result of long type.
ToLongFunction It represents a function that returns a result of long type.
UnaryOperator It represents an operation on a single operand that returnsa a result of the same type as its operand.

80
Q

What are Java Anonymous Classes?

A

Anonymous classes enable you to make your code more concise. They enable you to declare and instantiate a class at the same time. They are like local classes except that they do not have a name. Use them if you need to use a local class only once.

81
Q

What are Java Lambda Expressions?

A

One issue with anonymous classes is that if the implementation of your anonymous class is very simple, such as an interface that contains only one method, then the syntax of anonymous classes may seem unwieldy and unclear. In these cases, you’re usually trying to pass functionality as an argument to another method, such as what action should be taken when someone clicks a button. Lambda expressions enable you to do this, to treat functionality as method argument, or code as data.

The previous section, Anonymous Classes, shows you how to implement a base class without giving it a name. Although this is often more concise than a named class, for classes with only one method, even an anonymous class seems a bit excessive and cumbersome. Lambda expressions let you express instances of single-method classes more compactly.

Lambda expressions are one of the biggest new features of Java 8, and they introduce some important aspects of functional programming to Java. The most basic syntax of a lambda expression is:

parameter(s) -> expression

For example, we can use the .forEach method of the Iterable interface, which accepts a lambda expression as its argument:

List names = new ArrayList<>();

names. add(“Alice”);
names. add(“Bob”);
names. add(“Charlie”);
names. forEach(str -> System.out.println(str));

This will print out the names just as if we had used a for loop. The lambda syntax could also be done with an explicit type declaration for the parameter, but the compiler can infer the type from the value used. For multiple parameters, parentheses are required around them. Also, curly braces are optional for single statements but required for multiple. Finally, the return keyword is also optional for a single expression because the value will be returned by default.

82
Q

What is SDLC?

A

Software Development Lifecycle (SDLC)

SDLC is the series of steps that we go through when creating new products. It encompasses methodologies (broader categories of development concepts and practices) and frameworks (a more detailed implementation of a methodology’s ideas). We will be discussing the Waterfall and Agile methodologies in addition to the Scrum, Kanban, Scrumban, and eXtreme Programming frameworks (all of which are frameworks of the Agile methodology). Although the order/repetition of the steps in the two methodologies is different, they both contain the same overarching steps that are characteristic of SDLC as a whole; these are gathering requirements, analyzing those requirements, designing a solution, developing the solution, testing the solution, user acceptance testing (UAT), releasing the solution, and finally maintaining the product. These eight steps can be categorized into three phases: the design phase (gathering/analyzing requirements and designing the solution), the development phase (developing, testing, and UAT), and the deliver phase (release and maintenance). We’ll begin our journey into the methodologies and frameworks by first discussing the methodologies and how they implement/order these steps and phases.

83
Q

What is the Waterfall Methodology?

A

The Waterfall Methodology
Waterfall is a very rigid methodology that follows a strict series of steps. Waterfall practitioners follow each of the eight SDLC steps in order, never revisiting a previous stage; just like a natural waterfall, the methodology only flows in one direction. E.g., once development has begun, Waterfall practitioners accept no new requirements from the client. In fact, this exclusion of the client is one of the major drawbacks to Waterfall. Let’s further explore Waterfall’s drawbacks and benefits.

Waterfall Drawbacks
As stated in the previous section, the Waterfall methodology excludes the client in every step between requirement gathering and deployment - your client better have given you a complete set of requirements at the beginning because once development starts, you’re not accepting any new feature requests. Additionally, you should pray that they are satisfied with the end result because once you deploy the product, you are only maintaining existing features - never adding new ones. The one-direction flow makes changes to previous stages impossible. Finally, Waterfall practitioners do not test until all development has been completed, so a bug or problem that may have been developed months prior will not be noticed until the entire project has entered the testing phase.

Benefits of Waterfall
The same rigidness that hinders the methodology can also work to its advantage. There is no room for confusion in Waterfall because there is a clear barrier between each step, making it easy for team members to keep track of where they are in the project. This clear barrier also allows for a clean transfer of knowledge between steps. For example, when moving from development to testing, team members will already know every aspect of the project that will ever need to be tested; because there is no revisiting past steps, they do not have to worry about any future functionality in need of scrutiny. This clarity also applies to the entire Waterfall lifecycle - programmers have an understanding of what the finished product will look like and do as soon as the design phase has been completed because all requirements are gathered before design (or development, for that matter) begins. Lastly, unlike the Agile methodology (which we will detail in a bit), Waterfall does not require any specific procedural knowledge - followers simply intuitively move from one step and phase to the next.

84
Q

What is a User Story?

A

User Story: An individual feature of/requirement for a project in Agile development.

85
Q

What is an Epic?

A

Epic: A group of related features that is broken down into multiple user stories.

86
Q

What is a Story Point?

A

Story Point: A level of difficulty assigned to a user story through use of a sequence of numbers that increase with increasing difficulty.

87
Q

What is a Sprint?

A

Sprint: A brief period of development (almost always less than four weeks, sometimes as short as one week) generally culminating in a release of related features.

88
Q

What is a Velocity?

A

Velocity: The sum of story points of all user stories completed during a sprint. Velocity allows Agile teams to more accurately predict how many user stories can be completed in future sprints.

89
Q

What is Agile Methodology?

A

The Agile Methodology
Where Waterfall is rigid, Agile is fluid. This fluidity has brought popularity, largely owing to the ability to adjust to changing requirements and requests from the client. For now, let’s talk about the benefits and drawbacks of the methodology as a whole. Later, We will explore four Agile frameworks.

Agile Drawbacks
Although flexibility can be advantageous, it can also lead to bad practices. For example, developers may be tempted to avoid fully designing their solutions prior to implementation because they know that the methodology allows for revisiting past SDLC steps. This is not how Agile should be utilized. Rather, the Agile fluidity should be used to adapt to changing requirements from the client and unforeseen circumstances that are not simply the result of poor, or nonexistent, planning. Allowing for change can also encourage unpredictability - another drawback of the methodology. Finally, as we will detail when talking about the Agile frameworks, properly following Agile practices necessitates knowledge of those practices - the methodology is more complicated than the comparatively simple Waterfall approach.

Benefits of Agile
Although we highlighted the dangers of allowing for changing feature requests in the last section, the ability to handle and respond to these shifts is a benefit. Additionally, the Agile flexibility extends to release times - because the Agile release cycle is iterative, any features that cannot be included in the upcoming release can simply be made as part of the following deployment. Multiple releases also allows for faster movement through the testing phase because developers are testing a small set of features, not the entire project at once as in Waterfall. Lastly, the methodology allows for initial ambiguity. For example, suppose Feature B is built on top of Feature A. Because we have the ability to put both features in separate releases, we can wait until the release containing Feature A is deployed and we are in the design phase of the following iteration before designing Feature B. This allows for the solution to Feature B to be modified based on an implementation of Feature A that may be different than we had originally planned.

90
Q

What is a SCRUM Framework?

A

We will first explore Scrum, arguably the simplest of the Agile frameworks. It enforces certain ceremonies, led by a Scrum Master who ensures that the team is following Scrum practices. Development is broken into two to four week sprints.

Before the sprint begins, the team moves some user stories from the project backlog (the list of user stories for the entire project) to the sprint backlog (the list of features that the team is planning to complete in the upcoming sprint). Throughout the sprint, the Scrum Master leads 15 minute daily standups, daily meetings where each team member details the progress they made the previous day, their plans for the coming day, and any roadblocks they have run into. The standup creates an environment where each team member knows how the project in totality is progressing, even though they may only be working on one component. It also allows for a set time where programmers can ask their peers, who may have more expertise and experience in a specific area, or simply a fresh pair of eyes, for help with any issues. As any programmer can attest, there are some bugs that you will never find by yourself.

After the product is released at the end of each sprint, the team holds a final Scrum ceremony: the retrospective. Here, teams put any unaccomplished tasks back into the project backlog and discuss what went well in the sprint and how to continue that success, as well as what was unsuccessful and how to improve on those setbacks.

Scrum Advantages
Daily standups bring many benefits, particularly the ability to quickly identify any setbacks that developers on the team are experiencing and then quickly solve those problems with the help of others. The relatively short sprints allow for constant releases, which in turn incorporate the client throughout the process of developing the entire project. Involving the client allows for the team to adjust to new client feedback and feature requests, which results in an end product that more accurately reflects their client’s desires, leading to increased client satisfaction.

Scrum Disadvantages
As we touched on when discussing Agile, the very fluidity that gives Scrum benefits also brings in uncertainty. Because the final deadline and complete requirement list are not known at the beginning of the project, it is difficult to estimate costs or a final release date. Additionally, this fluidity results in feature creep, a continuous expansion of proposed functionalities. Feature creep occurs because Scrum followers are held to no firm deadlines, so there is no reason to exclude certain user stories in order to stick to a release date and they can unceasingly add new features, never truly completing the project. Finally, Scrum’s ceremonies require engagement from all team members in order to properly function. For example, the daily standup loses its effectiveness if a developer is running into setbacks but never voices them to the group.

91
Q

What is a Kanban Board?

A

The Kanban board, a vehicle for a visual representation of the progress of a project, is the hallmark trait of the Kanban framework.

There is no firm requirement for the number of columns on the board, but there should generally be at least one column per SDLC phase. Kanban cards, visual representations of a single user story or work item, are placed in the columns. Team members who have completed their current task can simply refer to the board and choose a new card from the backlog to work on. There should never be more tasks in progress - i.e. not in the backlog/equivalent column or release/equivalent column - than there are developers on the team.

Kanban Advantages
Kanban is event-driven, removing even the small pressure of sprint deadlines found in the Scrum framework. It also allows for specialists; for example, one team member can be a testing specialist. In this scenario, once user stories have been moved into the testing/equivalent column, the testing specialist can begin working on them and the developer who had previously been responsible for that task can start work on another card in the backlog. Specialization can result in developers building a stronger expertise in a particular area. Additionally, the Kanban board can always take new client requirements and is persistent throughout releases. Finally, it allows the entire team to view the current state and progress of the project.

Kanban Disadvantages
The capacity of the Kanban board also brings drawbacks, particularly the danger that the board’s size will grow to the point where it becomes unnecessarily complex and difficult to understand/navigate. Like Scrum, Kanban also requires commitment from its devotees - an out-of-date Kanban board doesn’t help (and can even hurt) the team because developers will end up working on the same tasks and will not have an accurate picture of the evolution of the project. But unlike Scrum (with timed sprints) and Waterfall (with a set project deadline from the beginning), this framework has no timing element, which can result in an even more extreme version of feature creep and constant release delays/uncertainty.

92
Q

What is a Scrumban?

A

We will only briefly touch on Scrumban, a combination of Scrum and Kanban. Scrumban pairs the visual representation of Kanban with the ceremonies and sprints of Scrum. Doing so mitigates Kanban’s timing issues with the help of Scrum’s sprints. It also gives Scrum practitioners the specialization capabilities found in Kanban (an argument between specialization and cross-functionality can be reserved for another time

93
Q

What is eXtreme Programming (XP)?

A

XP is the most verbose of the Agile frameworks we have examined. There are strict procedures designed to encourage XP’s values of communication, simplicity, feedback, courage, and respect. As these values would suggest, this framework seeks to go beyond improving product quality by also improving team cohesion and the lives and happiness of individual members. XP procedures include weekly cycles (one-week sprints), quarterly cycles (i.e. quarterly releases), continuous integration (ensuring that code from new sprints can easily be assimilated into the existing code base), incremental design (initial high-level design of features and functionalities, leaving the specifics for later), the use of user stories and epics, test-driven development (TDD), pair programming, and other practices. In addition, the XP team includes a member of the customer in order to fulfill the goal of faster feedback.

Let’s further detail TDD and pair programming because we may be implementing these practices at various points throughout training. TDD is the approach of designing the tests that your code must pass before writing the actual code (in contrast to the usual practice of writing the code then writing the tests), allowing the developer to have a clearer understanding of what their program must accomplish. But take note that using TDD is not an invitation to write test-specific code, your code should still be able to handle a variety of input, not just the input that you know your tests will give.

Pair programming is an approach where teams are broken into groups of two while developing. Each group includes a pilot and a navigator. The pilot is actively writing code, while the navigator is planning how the code that the pilot is writing at that moment will tie into the larger user story, epic, and project code base. Although this may seem like it will double development time, pair programming is actually more efficient than you may expect because the pairs can collaborate and solve issues faster and narrow their focus due to lessened responsibility.

XP Downsides
The amount of XP procedures and practices can make following the framework difficult even for dedicated teams. In addition, the involvement of the client on the development team can be a hindrance - non-technically inclined clients may insist on inefficient implementations or question logically sound programmatic approaches. XP’s weekly iterations can cause developers to sacrifice general best practices in order to make deadlines. For example, documentation may be written hastily and be incomplete. The frameworks short sprints and intimate inclusion of the customer can invite frequent changes, meaning that documentation can quickly become outdated.

Frequent iterations combined with incremental design can also be a dangerous combination as programmers may not have time within a sprint to refine their solutions to maximize code efficiency and good design principles; they may only have time to write code that simply clears the bar set by the customer requirements. Observing these drawbacks as a whole, it becomes clear that ironically, despite its lofty goal of improving employee happiness, this framework can actually be quite stressful to use.

XP Benefits
That being said, XP is not irredeemable. There can be advantages to such a close relationship with the customer - the constant communication minimizes or even erases the danger of sunk costs due to time spent developing features that, upon delivery, the client decides they no longer want or need. The framework’s focus on communication and pair programming can increase the group’s cohesion, openness, awareness of the entire project, and commitment to each other. Finally, although its pace can be stressful, the brief development periods and focus on continuous integration result in the quick delivery of working solutions.

94
Q

What is Agile Planning?

A
Agile Planning
Now that we've explored various Agile frameworks. let's revisit the terms we defined at the beginning of this module and detail how they are used in project planning. At the beginning of a sprint (if using Scrum, Scrumban, or XP) or upon receiving a new feature request (if using Kanban), teams form client requirements into epics and then break those epics into individual user stories. After that process is complete, each user story is assigned story points. In our practices, we will be assigning story points using the Fibonacci sequence - i.e. a 1 will be the absolute easiest task, 2 the next most difficult, followed by 3, 5, 8, etc. Lastly, each story is given a time estimate.

The art of assigning story points and time estimates is just that - an art. It takes practice to gain a solid understanding of what tasks are easier/more difficult than others for your team of developers, so don’t be discouraged if your initial attempts are not particularly accurate - that’s part of the learning process. Even though these estimates will not be perfect, they allow the group to have a better idea of which tasks will be easier/more difficult and take more/less time, so they can plan accordingly and accomplish goals with more ease than they would by simply flying blindly into development.

95
Q

What are Java Generics?

A

Generics in Java
The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects. It makes the code stable by detecting the bugs at compile time.

Before generics, we can store any type of objects in the collection, i.e., non-generic. Now generics force the java programmer to store a specific type of objects.

Advantage of Java Generics
There are mainly 3 advantages of generics. They are as follows:

1) Type-safety: We can hold only a single type of objects in generics. It doesn?t allow to store other objects. Without Generics, we can store any type of objects.
2) Type casting is not required: There is no need to typecast the object. Before Generics, we need to type cast.
3) Compile-Time Checking: It is checked at compile time so problem will not occur at runtime. The good programming strategy says it is far better to handle the problem at compile time than runtime.

96
Q

What are Java Generic Wildcards?

A

The ? (question mark) symbol represents the wildcard element. It means any type. If we write extends Number>, it means any child class of Number, e.g., Integer, Float, and double. Now we can call the method of Number class through any child class object.

We can use a wildcard as a type of a parameter, field, return type, or local variable. However, it is not allowed to use a wildcard as a type argument for a generic method invocation, a generic class instance creation, or a supertype.

97
Q

What are Generic Methods?

A

Like the generic class, we can create a generic method that can accept any type of arguments. Here, the scope of arguments is limited to the method where it is declared. It allows static as well as non-static methods.

98
Q

What are Java Annotations?

A

Java Annotation is a tag that represents the metadata i.e. attached with class, interface, methods or fields to indicate some additional information which can be used by java compiler and JVM.

Annotations in Java are used to provide additional information, so it is an alternative option for XML and Java marker interfaces.

Built-In Java Annotations used in Java code

@Override
@SuppressWarnings
@Deprecated

Built-In Java Annotations used in other annotations
@Target
@Retention
@Inherited
@Documented
99
Q

What is TDD and what is the process?

A

When developing software, it is important to ensure that most if not all of the code being written is tested to verify the functionality of the code. One way to ensure this is to follow a process called test-driven development, or TDD.

TDD Process
The TDD process consists of writing unit tests first, before the application code has been written. Then, code can be written to make the test pass and the process can be completed for each piece of functionality required. Thus, the process is:

Write a unit test
Run the test => test will fail
Fix the test by writing application code
Retest until the test passes
Repeat
Following the TDD process can be useful for ensuring that a valid unit tests always exists for any class or method that is written. Later, when refactoring code, the unit tests give us confidence that we can change the source code without breaking existing functionality. If we mess up somewhere, when the unit tests are run we can pinpoint exactly where the problem lies. This makes debugging much easier.
100
Q

What is Unit Testing?

A

Unit testing is the testing of individual software components in isolation from the rest of the system. This is done by writing unit tests which execute the code we want to inspect. When the code under test deviates from an expected outcome or behavior, the test will fail. If a test passes, it means the application performs as expected (unless there is a problem with the test itself). In Java, the most common unit testing framework is called JUnit.

101
Q

What is a constructor?

A

In Java, a constructor is a block of codes similar to the method. It is called when an instance of the object is created, and memory is allocated for the object.

It is a special type of method which is used to initialize the object.

102
Q

When are constructors called?

A

When an object is created, compiler makes sure that constructors for all of its subobjects (its member and inherited objects) are called. If members have default constructors or constructor without parameter then these constructors are called automatically, otherwise parameterized constructors can be called using initializer list.

Note: It is called constructor because it constructs the values at the time of object creation. It is not necessary to write a constructor for a class. It is because java compiler creates a default constructor if your class doesn’t have any.

103
Q

What are the rules to remember while creating a constructor?

A

There are three rules defined for the constructor.

  • Constructor name must be the same as its class name
  • A Constructor must have no explicit return type
  • A Java constructor cannot be abstract, static, final, and synchronized
104
Q

What types of constructors are there?

A
  • Default Constructor

- Parameterized Constructor

105
Q

What is a Default Constructor?

A

The default constructor is a no-args constructor that the Java compiler inserts on your behalf; it contains a default call to super(); which is the default behavior. If you implement any constructor then you no longer receive a default constructor.

Note : If there is no constructor in the class, the compiler adds a default constructor

106
Q

What is a Parameterized Constructor?

A

A constructor which has a specific number of parameters is called a parameterized constructor.

The parameterized constructor is used to provide different values to the distinct objects. However, you can provide the same values also.

107
Q

What is Constructor Overloading?

A

In Java, a constructor is just like a method but without return type. It can also be overloaded like Java methods.

Constructor overloading in Java is a technique of having more than one constructor with different parameter lists. They are arranged in a way that each constructor performs a different task. They are differentiated by the compiler by the number of parameters in the list and their types.

108
Q

What are the differences between a constructor and a method?

A

Constructor :

  • A constructor is used to initialize the state of an object.
  • A constructor must not have a return type.
  • The constructor is invoked implicitly.
  • The Java compiler provides a default constructor if you don’t have any constructor in a class.
  • The constructor name must be same as the class name.

Method :

  • A method is used to expose the behavior of an object.
  • A method must have a return type.
  • The method is invoked explicitly.
  • The method is not provided by the compiler in any case.
  • The method name may or may not be same as class name.
109
Q

What is Generalization?

A

Generalization
Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass. Shared characteristics can be attributes, associations, or methods.

Eg : The classes Piece of Luggage and Piece of Cargo partially share the same attributes. From a domain perspective, the two classes are also very similar. During generalization, the shared characteristics are combined and used to create a new superclass Freight . Piece of Luggage and Piece of Cargo become subclasses of the class Freight. Therefore the properties that are common to the classes Piece of Luggage and Piece of Cargo are placed in the superclass Freight - Identification, Weight and ID-Number are those properties.

110
Q

What is Specialization?

A

Specialization

Specialization means creating new subclasses from an existing class. If it turns out that certain attributes, associations, or methods only apply to some of the objects of the class, a subclass can be created.