Terms Flashcards

(72 cards)

1
Q

Casting

A

Assigning a value of one type to a variable of another type is known as Type Casting.

public class Test
{
    public static void main(String[] args)
    {
      int i = 100;
      long l = i;	//no explicit type casting required
      float f = l;	//no explicit type casting required
      System.out.println("Int value "+i);
      System.out.println("Long value "+l);
      System.out.println("Float value "+f);
    }
}
Output: Int value 100
Long value 100
Float value 100.0
https://www.studytonight.com/java/type-casting-in-java
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Truncation

A

Cutting off the digits to the right of a decimal point.
i.e.
double div = 5/2;
System.out.println(div) = 2

In order to print out “2.5” you would need to make div = 5.0/2, 5/2.0, or 5.0/2.0.

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

A thread (multithreading)

A

A thread is a subset of a process. An example of a process is Google Chrome and a thread would be a tab. A thread shares the same address as its parent process.

https://www.youtube.com/watch?v=b5sj13Z7aho

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

What does “static” do?

A
\+It creates an element that's independent of any object
When a member is declared static, it can be accessed before any objects of its class are created, and without reference to any object.
-https://www.geeksforgeeks.org/static-keyword-java/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does “public” do?

A

It creates a class element that other classes can use.

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

Overloaded method

A
Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. It is similar to constructor overloading in Java, that allows a class to have more than one constructor having different argument lists.
Method overloading is an example of Static Polymorphism.

https://beginnersbook.com/2013/05/constructor-overloading/

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

Overloaded constructor

A

+Like methods, we can overload constructors for creating objects in different ways. Compiler differentiates constructors on the basis of numbers of parameters, types of the parameters and order of the parameters.
-https://www.geeksforgeeks.org/constructors-in-java/

+Sometimes there is a need of initializing an object in different ways. This can be done using constructor overloading. For example, Thread class has 8 types of constructors. If we do not want to specify anything about a thread then we can simply use default constructor of Thread class, however if we need to specify thread name, then we may call the parameterized constructor of Thread class with a String args like this:

Thread t= new Thread (“ MyThread “);

https://beginnersbook.com/2013/05/constructor-overloading/

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

What does “IDE” stand for?

A

Integrated Development Environment

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

What does an IDE do?

A

An IDE is a set of tools that helps you create software programs. It provides an editor, a compiler, a debugger, and other tools.

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

What is “source code”?

A

The programs that we write in text are called source code. (This is true of any programming language, not just Java.). But whatever text editor a programmer uses, the product is the same: Java source code.

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

Describe a “compiler”

A

A compiler translates the source code you’ve written into a form that a computer can understand. In many cases, this is a string of ones and zeroes.

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

POJO

A

Pojo: Plain Old Java Object is a Java object not bound by any restriction other than those forced by the Java Language Specification. I.e., a POJO should not have to

Extend prespecified classes
Implement prespecified interface
Contain prespecified annotations

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

What is POJO, Bean, Normal Class in easy language?

A

Normal Class: A Java class

Java Beans:

All properties private (use getters/setters)
A public no-argument constructor
Implements Serializable.
Pojo: Plain Old Java Object is a Java object not bound by any restriction other than those forced by the Java Language Specification. I.e., a POJO should not have to

Extend prespecified classes
Implement prespecified interface
Contain prespecified annotations

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

What is Java’s API?

A

The Application Program Interface, a list of all Java’s classes and their public properties.

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

What does the Java keyword static do?

A

It creates a class element that’s independent of any object.

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

How does Java’s do-while loop work?

A

It executes its group of statements at least once, and it repeats them long as its condition is met.

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

What’s the difference between declaring instance variables and local variables in a Java program?

A

You declare instance variables at the start of a class, but you declare local variables inside methods.

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

Constructor

A

A constructor constructs an instance of a class.
https://wecancodeit.github.io/java-slides/objects/constructors/#/9

Constructors are used to initialize the object’s state.
https://www.geeksforgeeks.org/constructors-in-java/

The job of a constructor is to construct an object. A constructor’s name is the same as the name of the type of thing it’s constructing:
https://wecancodeit.github.io/java-slides/fundamentals/reading-console-input/#/4

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

Arrays vs. Array List

A

-The capacity of an Array is fixed.
Where as, ArrayList can increase and decrease size dynamically.
-An Array is a collection of similar items.
Where as, ArrayList can hold item of different types.
-Array is in the System namespace.
Where as, ArrayList is in the System.Collections namespace.
-An Array can have multiple dimensions.
Where as, ArrayList always has exactly one dimension.
-We can set the lower bound of an Array.
Where as, the lower bound of an ArrayList is always zero.
-Array is faster and that is because ArrayList uses a fixed amount of array.
However when you add an element to the ArrayList and it overflows. It creates a new Array and copies every element from the old one to the new one.
You will only feel this if you add to often.
-Since the add from ArrayList is O(n) and the add to the Array is O(1).
However because ArrayList uses an Array is faster to search O(1) in it than normal lists O(n
https://www.codeproject.com/Questions/394625/Which-is-better-array-ArrayList-or-List-in-terms-o

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

Maps

A

A map is a construct that allows us to pair keys and values. Map is a parameterized type.
https://wecancodeit.github.io/java-slides/objects/maps/#/1

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

List

A

characterized by being ordered. May contain duplicate elements.
elements are unordered. Elements must be unique.

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

Set

A

Elements are unordered. Elements must be unique.

https://wecancodeit.github.io/java-slides/objects/maps/#/6

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

APIE

A

[ A ] bstraction

[ P ] olymporphism

[ I ] nheritance

[ E ] ncapsulation

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

Encapsulation

A

+Encapsulation at its simplest is hiding away information that isn’t necessary to share. The more knowledge we have about an object, the more complex our problem solving becomes.
-https://wecancodeit.github.io/java-slides/objects/a-pie/#/11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Interface
``` +It is similar to class. It is a collection of abstract methods.A class implements an interface, thereby inheriting the abstract methods of the interface. -https://www.tutorialspoint.com/java/java_interfaces.htm ``` +Interfaces are used to implement abstraction. So the question arises why use interfaces when we have abstract classes? The reason is, abstract classes may contain non-final variables, whereas variables in interface are final, public and static. -https://www.geeksforgeeks.org/interfaces-in-java/
26
Encapsulation
+Encapsulation at its simplest is hiding away information that isn’t necessary to share. The more knowledge we have about an object, the more complex our problem solving becomes. -https://wecancodeit.github.io/java-slides/objects/a-pie/#/11 +Encapsulation is the practice of hiding information about an object from other objects. We do this so that the responsibility for manipulating state is limited to one object. -https://wecancodeit.github.io/java-slides/objects/encapsulation/#/4
27
Final
+the final keyword is used in several contexts to define an entity that can only be assigned once. +Once a final variable has been assigned, it always contains the same value. If a final variable holds a reference to an object, then the state of the object may be changed by operations on the object, but the variable will always refer to the same object (this property of final is called non-transitivity https://en.wikipedia.org/wiki/Final_(Java)
28
Hibernate
+is an object-relational mapping tool for the Java programming language. It provides a framework for mapping an object-oriented domain model to a relational database...Hibernate's primary feature is mapping from Java classes to database tables, and mapping from Java data types to SQL data types. Hibernate also provides data query and retrieval facilities. It generates SQL calls and relieves the developer from the manual handling and object conversion of the result set.
29
Literal
+Any constant value which can be assigned to the variable is called as literal/constant. ``` // Here 100 is a constant/literal. int x = 100; -https://www.geeksforgeeks.org/literals-in-java/ ``` +System.out.println("Hello, World!"); "Hello, World!" is a String literal. It’s a String because it’s a sequence of characters surrounded by quotation marks. It’s a literal because it always has that value. -https://wecancodeit.github.io/java-slides/fundamentals/basic-types-and-variables/#/1
30
PascalCase
The naming convention for classes. Starts with a capital letter.
31
Variable
+Variables store a value, but allow us to change the value that is stored. -https://wecancodeit.github.io/java-slides/fundamentals/basic-types-and-variables/#/3
32
public static void main(string[] args)
https://www.journaldev.com/12552/public-static-void-main-string-args-java-main-method +Let's split it and understand one by one. 1. public- Here public is an access specifier which allows thhe main method to be accessble everywhere. 2. static- static helps main method to get loaded without getting alled by any instance/object. 3. void- void clarifies that the main method will not return any value. 4. main- It's the name of the method. 5. String[] args- Here we are defining a String array to pass arguments at command line. args is the variable name of the String array. It can be changed to anything such as String [] a. - https://www.youth4work.com/Talent/Core-Java/Forum/118313-what-is-meaning-of-public-static-void-mainstring-args
33
Initializing
+Initializing is assigning a value to declared variable | -https://wecancodeit.github.io/java-slides/fundamentals/basic-types-and-variables/#/7
34
Strings
+String is a sequence of characters. In java, objects of String are immutable which means a constant and cannot be changed once created. -https://www.geeksforgeeks.org/string-class-in-java/ ``` +In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings. -https://www.tutorialspoint.com/java/java_strings.htm ```
35
Strings
+String is a sequence of characters. In java, objects of String are immutable which means a constant and cannot be changed once created. -https://www.geeksforgeeks.org/string-class-in-java/ ``` +In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings. -https://www.tutorialspoint.com/java/java_strings.htm ``` +https://docs.oracle.com/javase/9/docs/api/java/lang/String.html -https://docs.oracle.com/javase/9/docs/api/java/lang/String.html
36
Strings
+String is a sequence of characters. In java, objects of String are immutable which means a constant and cannot be changed once created. -https://www.geeksforgeeks.org/string-class-in-java/ ``` +In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings. -https://www.tutorialspoint.com/java/java_strings.htm ``` +A String is an abstraction representing a sequence of characters, so it contains an instance variable containing those characters. -https://wecancodeit.github.io/java-slides/objects/constructors/#/5 +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); -https://docs.oracle.com/javase/9/docs/api/java/lang/String.html ``` + a String represents a sequence of primitive chars. Methods we call on Strings create and return new Strings rather than changing the original String [because] Strings in Java are immutable. -https://wecancodeit.github.io/java-slides/fundamentals/strings/#/1
37
Switch/Case Statements
Sometimes, we can use a switch/case statement to replace several if/else statements.We can use a switch/case statement to execute one or more statements based on a value: String ageGroup = "youngster"; switch (ageGroup) { case "adult": System.out.println("You can ride the rollercoaster!"); case "youngster": System.out.println("The teacups are fun."); break; default: System.out.println("Oh, you must be a toddler. Toddle on!"); } If you are landing in a huge switch-case or if-else block, switch to other techniques like polymorphism. Just find out the behavior of the object and try to encapsulate it if possible. https: //www.geeksforgeeks.org/switch-statement-in-java/ https: //www.geeksforgeeks.org/switch-vs-else/ https: //wecancodeit.github.io/java-slides/fundamentals/conditionals/#/12
38
What are the 8 primitive data types in Java?
``` 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 ```
39
Signature
The part of the method before the opening curly bracket ({) is called its signature. https://wecancodeit.github.io/java-slides/fundamentals/reading-console-input/#/7
40
Branching Statements
In addition to the decision making and looping statements, we have branching statements. These interrupt the normal top-to-bottom execution of our code. There are three: break, continue, and return.
41
Methods
+Methods are messages we send to objects. | -https://wecancodeit.github.io/java-slides/objects/constructors/#/1
42
Static
``` +The static keyword in Java means that the variable or function is shared between all instances of that class as it belongs to the type, not the actual objects themselves. -https://stackoverflow.com/questions/413898/what-does-the-static-keyword-do-in-a-class ``` +In the Java programming language, the keyword static indicates that the particular member belongs to a type itself, rather than to an instance of that type. This means that only one instance of that static member is created which is shared across all instances of the class. ``` Compelling reasons to use static fields? Answer: When the value of variable is independent of objects AND/OR When the value is supposed to be shared across all objects. Since static variables belong to a class, they can be accessed directly using class name and don’t need any object reference static variables can only be declared at the class level static fields can be accessed without object initialization Although we can access static fields using an object reference (like ford.numberOfCars++) , we should refrain from using it as in this case it becomes difficult to figure whether it’s an instance variable or a class variable; instead, we should always refer to static variables using class name (for example, in this case, Car.numberOfCars++) https://www.baeldung.com/java-static ```
43
Method signature
+The combination of the method name and parameter types is called its method signature. This is how Java identifies which method we are calling. -https://wecancodeit.github.io/java-slides/objects/constructors/#/4
44
Methods
+Methods are messages we send to objects. -https://wecancodeit.github.io/java-slides/objects/constructors/#/1 +A method whose return type is anything other than void must return a response. We do this with the return statement. -https://wecancodeit.github.io/java-slides/objects/constructors/#/5
45
Objects
+Objects are Instances of a class | -https://wecancodeit.github.io/java-slides/objects/constructors/#/6
46
OOP
Stands for "Obejct Oriented Programming" +Object Oriented Programming is all about creating objects (instances of a class) and communicating with those objects (calling methods). Objects contain instance variables that contain the state of an object, describing the object’s attributes. -https://wecancodeit.github.io/java-slides/objects/constructors/#/6
47
Constructor
A constructor constructs an instance of a class, or put another way, constructs an OBJECT.
48
Constructor
+A constructor constructs an instance of a class, or put another way, constructs an OBJECT. -https://wecancodeit.github.io/java-slides/objects/constructors/#/9
49
Constructor
+A constructor constructs an instance of a class, or put another way, constructs an OBJECT. -https://wecancodeit.github.io/java-slides/objects/constructors/#/9 +When we want to initialize attributes of an object, we create our own constructor that accepts parameters, just like methods that accept parameters. https://wecancodeit.github.io/java-slides/objects/constructors/#/10 ``` +Constructors are used to initialize the object’s state. Like methods, a constructor also contains collection of statements(i.e. instructions) that are executed at time of Object creation. Constructor(s) of a class must has same name as the class name in which it resides. A constructor in Java can not be abstract, final, static and Synchronized. Access modifiers can be used in constructor declaration to control its access i.e which other class can call the constructor. -https://www.geeksforgeeks.org/constructors-in-java/ ```
50
Default constructor
+If we haven’t explicitly defined a constructor for our class, the compiler creates a constructor for us that doesn’t accept any arguments and does basic instance construction. It is also know as a "No arguments constructor" - https://wecancodeit.github.io/java-slides/objects/constructors/#/9 https: //www.geeksforgeeks.org/constructors-in-java/ +All classes have constructors, whether you define one or not, because Java automatically provides a default constructor that initializes all member variables to zero. However, once you define your own constructor, the default constructor is no longer used. -https://www.tutorialspoint.com/java/java_constructors.htm
51
Method vs. Constructor
+ 1. A constructor doesn’t have a return type. 2. The name of the constructor must be the same as the name of the class. 3. Unlike methods, constructors are not considered members of a class. 4. A constructor is called automatically when a new instance of an object is created. - https://www.dummies.com/programming/java/how-to-use-a-constructor-in-java/
52
Arrray vs ArrayList
https://javaconceptoftheday.com/differences-between-array-vs-arraylist-in-java/ +An array is basic functionality provided by Java. ArrayList is part of collection framework in Java. Therefore array members are accessed using [], while ArrayList has a set of methods to access elements and modify them. +Array is a fixed size data structure while ArrayList is not. One need not to mention the size of Arraylist while creating its object. Even if we specify some initial capacity, we can add more elements. -https://www.geeksforgeeks.org/array-vs-arraylist-in-java/ +An ArrayList, like an array is iterable,so we can use the enhanced for loop with it -https://wecancodeit.github.io/java-slides/objects/arraylists/#/12
53
Autoboxing
Java does something called autoboxing to automatically convert between primitives and objects. This happens with ArrayLists when you want to have one full of primitives; it automatically converts the primatives (ie ints) into objects.
54
Enhanced For Loop
Java also includes another version of for loop introduced in Java 5. Enhanced for loop provides a simpler way to iterate through the elements of a collection or array. It is inflexible and should be used only when there is a need to iterate through the elements in sequential manner without knowing the index of currently processed element. EX: for (T element:Collection obj/array) { statement(s) } -https://www.geeksforgeeks.org/loops-in-java/
55
Maps
+A map is a construct that allows us to pair keys and values. Maps are sometimes referred to as tables or dictionaries. +Map is a parameterized type, so we declare it thus, specifying the types for key and value: Map students; +Map is an interface, an abstract type rather than a concrete type, so in order to instantiate (create) a map, we must call the constructor for a concrete type. The most common concrete Map is HashMap:
56
Maps
+A map is a construct that allows us to pair keys and values. Maps are sometimes referred to as tables or dictionaries. +Map is a parameterized type, so we declare it thus, specifying the types for key and value: Map students; +Map is an interface, an abstract type rather than a concrete type, so in order to instantiate (create) a map, we must call the constructor for a concrete type. The most common concrete Map is HashMap: +We know that we could use an array or an ArrayList to hold collections of things, so why Map?...Maps make this easier. Also, what if there were 20,000 students and the one we were looking for was 19,998th in our list? Maps also perform better for doing lookups like this. Maps are part of the JCF (Java Collections Framework), but a Map is not a Collection. Remember the two types of Collection we have talked about? List: characterized by being ordered. May contain duplicate elements. Set: elements are unordered. Elements must be unique. Map keys can not be duplicated and we don’t care about their order, so we use a Set to represent them. Map values can be duplicated, but their order isn’t significant. They don’t fit our concepts of a List or a Set. For these, we use the parent of List and Set, Collection. A Collection promises to be no more than a collection of elements over which you can iterate.
57
Abstraction
+We create abstractions to simplify our program domain. They allow us to focus on the problem we are solving rather than getting lost in minute details. -https://wecancodeit.github.io/java-slides/objects/a-pie/#/3 Interfaces are used to achieve total abstraction.
58
Abstraction
+We create abstractions to simplify our program domain. They allow us to focus on the problem we are solving rather than getting lost in minute details. -https://wecancodeit.github.io/java-slides/objects/a-pie/#/3 +We are creating abstractions in the small whenever we: -->name a variable -->create (and name) a method -->create (and name) a class -->simplify an attribute by representing it as a number (hunger) or a label (“purple”) This is why naming is so important: we need to accurately convey the abstraction we’re describing to those that follow (as well as our later selves). We apply the other OO principles (PIE) to create meaningful and useful abstractions of more complex concepts. https://wecancodeit.github.io/java-slides/objects/a-pie/#/4
59
Polymorphism
Project(s) demonstrating concept: VIRTUAL PETS ``` +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. -https://www.tutorialspoint.com/java/java_polymorphism.htm ``` +We also implement polymorphism by: - ->extending a parent class (a String isA Object) - ->implementing an interface (an ArrayList isA List isA Collection isA Iterable) https: //wecancodeit.github.io/java-slides/objects/a-pie/#/8
60
Method Overriding
``` +A method that redefines a method from a superclass is said to override that method. A great example of this are the toString, equals, and hashCode methods from java.lang.Object that we have discussed. (Remember, Object is the superclass of all classes.) -https://wecancodeit.github.io/java-slides/objects/a-pie/#/7 ```
61
Inheritance
+Inheritance is the mechanism whereby a class inherits behavior from a superclass. We call this extending the superclass. Recall that all classes, whether we tell them to or not, implicitly extend Object. Sometimes we create types (classes) that only exist so that they may be extended. We use the keyword abstract to create these abstract classes, which may also declare abstract methods. The Java Collections Framework has several great examples of using inheritance and polymorphism: the Collections, Lists, and Maps that you know and love. -https://wecancodeit.github.io/java-slides/objects/a-pie/#/9
62
Encapsulation
+Encapsulation at its simplest is hiding away information that isn’t necessary to share. The more knowledge we have about an object, the more complex our problem solving becomes. -https://wecancodeit.github.io/java-slides/objects/a-pie/#/11 +Other way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield. - ->Encapsulation can be achieved by: Declaring all the variables in the class as private and writing public methods in the class to set and get the values of variables. - -> As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding. ``` Advantages of Encapsulation --> INCREASED FLEXIBILITY: We can make the variables of the class as read-only or write-only depending on our requirement. If we wish to make the variables as read-only then we have to omit the setter methods like setName(), setAge() etc. from the above program or if we wish to make the variables as write-only then we have to omit the get methods like getName(), getAge() etc. from the above program https://www.geeksforgeeks.org/encapsulation-in-java/ ```
63
What database did you use for workspace hub
Alan: I would talk about how you used JPA to create and manage a relational database that kept track of x y and z in the workspace hub application...then talk about how you queried the data to filter out things like parking and cost. You can mention that the google maps api was also integrated into the project to check locations of the workspaces...hows that?
64
JPA
Java Persistence API is a collection of classes and methods to persistently store the vast amounts of data into a database which is provided by the Oracle Corporation.
65
JSON
JSON: JavaScript Object Notation. JSON is a syntax for storing and exchanging data. JSON is text, written with JavaScript object notation https://www.w3schools.com/js/js_json_intro.asp
66
CRUD
CRUD is an acronym for the four basic types of SQL commands: Create , Read , Update , Delete . https://docs.jboss.org/tools/3.3.0.Final/en/seam_tools_ref_guide/html/crud_database_application.html
67
IntelliJ
?
68
What does the static keyword mean in a method signature?
static means that the method can be called without first creating an instance (ie. an object) of the class.
69
What is a local variable?
+a variable declared within a method | - Head First pg. 49
70
What are arguments?
+Values sent to a method by calling the code | - Head First pg. 49
71
Signature or Method Signature
+The part of the method before the opening curly bracket ({) is called its signature. The signature of the nextLine() method is: public String nextLine() String indicates the method's return type. This is how it responds when we talk to it. When we call nextLine(), its response is a String: public String nextLine() -https://wecancodeit.github.io/java-slides/fundamentals/reading-console-input/#/7
72
Operand and Operator
+ The value is called an operand, while the operation (to be performed between the two operands) is defined by an operator: Ex: x + y In this example "x" and "y" are the operands and "+" is the operator. - https://www.w3schools.com/java/java_operators.asp