Enterprise: Week 1 Flashcards
(110 cards)
What are environment variables?
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.
What are package managers?
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.
What are the basic linux commands?
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.
What are Flags Commands?
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.
What is the most important Linux Command?
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
What are the directory commands?
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.
What are the General Purpose Commands?
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»_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
What are the File Commands?
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.
What are the 3 File Permissions?
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 do you view permissions?
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 do you change permissions?
You can change the permissions on a file using the chmod or change file mode bits command.
What is Git?
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.
What is GitHub?
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.
What is Git Branching?
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.
What is a JDK?
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.
What is a JRE?
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.
What is a JVM?
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.
OOP: What is inheritance?
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.
OOP: What is Polymorphism?
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.
OOP: What is encapsulation?
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.
What are the 4 types of java access modifiers?
- private: within class
- default: within class, package
- protected: within class, package, by subclass
- public: class, package, subclass, outside package
OOP: What is abstraction?
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.
What is a class?
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.
What is an object?
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.