Java Flashcards

(49 cards)

1
Q

What is Java?

A
  • A commonly used OOP language

- It is a complied language

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

Why use Java?

A
  • Widely used
  • Lots of documentation
  • Great exception handling
  • Lots of environments support Java
  • Forwards compatible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is Java 100% OOP?

A

No, primitives are not objects.

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

What is the JDK?

A

The Java Development Kit contains compiler and debugger tools to compile the Java Source Code. Also contains the JRE and JVM

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

What is the JRE?

A

The Java Runtime Environment provides an environment and in that environment the JVM runs the compiled byte code. Also contains the JVM and library

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

What is the JVM?

A

The Java Virtual Machine creates a layer of abstraction from the Java Code and the computer environment. It is used to convert java bytecode to machine readable code.

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

What is a State?

A

Properties of an object

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

What is a behaviour?

A

Actions that an object can take

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

What is an Object?

A

An object is an instantiation of a class

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

What is a class?

A

A class is the blueprints that provides the States and Behaviors its instantiated object will have.

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

What are the class members?

A
  • Instance variables
  • Methods
  • Constructors
  • Inner class
  • static/instance blocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the types of variables?

A
  • Instance
  • Local
  • Static
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the scopes of variables?

A
  • Class–inside class
  • Method–inside method
  • Block–inside for or if statements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the Access Modifiers?

A
  • public–globally accessible
  • private–accessible only within that class
  • protected–accessible only within that package and its sublclasses
  • default–accessible only within that package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the Non-Access Modifiers?

A
  • static
  • final
  • abstract
  • synchronized
  • volatile
  • transient
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the Static Modifier?

A

variable or function belongs to all instances of that class as it belongs to the type, not the actual objects themselves

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

What is the Final Modifer?

A

Define an entity that can only be assigned once. Once a final variable has been assigned, it cannot be changed.

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

What is the Abstract Modifier?

A

used for the purpose of extending.

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

What is the synchronized modifier?

A

used for threads. accessed by only one thread at a time

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

What is the Volatile Modifier?

A

Used for threads. lets JVM know that a thread accessing a variable must merge its own private copy with the master copy in memory.

21
Q

What is the Transient Modifier?

A

used in serialization. field that is transient will not be sent at all and will appear as null on the other end

22
Q

What is a Constructor?

A

A special method used to create an instance of a class

23
Q

What are the types of Constructors?

A
  • args
  • no-args
  • default
24
Q

What are the four pillars of Object Oriented Programming?

A
  • abstraction
  • inheritance
  • encapsulation
  • polymorphism
25
What is abstraction?
it is focused on the concept of reusability which is achieved using generalization or specialization.
26
How do you achieve abstraction?
- abstract class | - frameworks
27
What is an Abstract class?
- a class that would denote a hierarchy between itself and the class extending it. - can only extend one abstract class.
28
What is an Interface?
- an interface can be implemented many times | - all methods of an interface must be implemented
29
What is Polymorphism?
The concept in java that objects can have the same states and behaviors, and are interchangeable
30
How do you achieve Polymorphism?
- method overloading | - method overriding
31
What are the types of Polymorphism?
- Compile time polymorphism (static) | - Runtime polymorphism (dynamic)
32
What is inheritance?
The concept that classes can share states and behaviors through extension
33
How do you achieve inheritance?
extend a class
34
What is Encapsulation?
Its a technique used to control an object's accessibility to its states
35
What is the hashcode?
It is an identifier for an object that has been converted to an integer
36
What is the Stack?
- refers to JavaStackMemory | - smaller than heap
37
What is the Heap?
-refers to the Java Heap Space, which allocates memory to Objects and JRE classes
38
What is the Finally Keyword?
- used in try/catch/finally block | - makes it execute no matter what, even if an exception is thrown
39
What is the Finalize Keyword?
-method used in garbage collection to invoke the JVM figures out that a particular instance should be garbage collector
40
What is an exception?
- Extends Throwable | - they are events in execution that deviate from the normal flow of execution.
41
What is throw?
method body to invoke an exception
42
What is throws?
method signature, used to declare an exception
43
What is the Garbage Collector?
a long running thread which gets rid of objects that no longer hold a reference in the heap to free up space
44
What is runtime?
when your compiled code is run when a user uses the application
45
What is compile time?
when the JVM compiles your java code into bytecode
46
What is a String?
- Immutable - stored in string pool - thread safe
47
What is a StringBuilder?
- mutable | - for strings that are changing rapidly
48
What is a StringBuffer?
- mutable - synchronized - slower
49
What is serialization?
is the process where java objects are converted to bytestreams