Java Flashcards

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
Q

What is abstraction?

A

it is focused on the concept of reusability which is achieved using generalization or specialization.

26
Q

How do you achieve abstraction?

A
  • abstract class

- frameworks

27
Q

What is an Abstract class?

A
  • a class that would denote a hierarchy between itself and the class extending it.
  • can only extend one abstract class.
28
Q

What is an Interface?

A
  • an interface can be implemented many times

- all methods of an interface must be implemented

29
Q

What is Polymorphism?

A

The concept in java that objects can have the same states and behaviors, and are interchangeable

30
Q

How do you achieve Polymorphism?

A
  • method overloading

- method overriding

31
Q

What are the types of Polymorphism?

A
  • Compile time polymorphism (static)

- Runtime polymorphism (dynamic)

32
Q

What is inheritance?

A

The concept that classes can share states and behaviors through extension

33
Q

How do you achieve inheritance?

A

extend a class

34
Q

What is Encapsulation?

A

Its a technique used to control an object’s accessibility to its states

35
Q

What is the hashcode?

A

It is an identifier for an object that has been converted to an integer

36
Q

What is the Stack?

A
  • refers to JavaStackMemory

- smaller than heap

37
Q

What is the Heap?

A

-refers to the Java Heap Space, which allocates memory to Objects and JRE classes

38
Q

What is the Finally Keyword?

A
  • used in try/catch/finally block

- makes it execute no matter what, even if an exception is thrown

39
Q

What is the Finalize Keyword?

A

-method used in garbage collection to invoke the JVM figures out that a particular instance should be garbage collector

40
Q

What is an exception?

A
  • Extends Throwable

- they are events in execution that deviate from the normal flow of execution.

41
Q

What is throw?

A

method body to invoke an exception

42
Q

What is throws?

A

method signature, used to declare an exception

43
Q

What is the Garbage Collector?

A

a long running thread which gets rid of objects that no longer hold a reference in the heap to free up space

44
Q

What is runtime?

A

when your compiled code is run when a user uses the application

45
Q

What is compile time?

A

when the JVM compiles your java code into bytecode

46
Q

What is a String?

A
  • Immutable
  • stored in string pool
  • thread safe
47
Q

What is a StringBuilder?

A
  • mutable

- for strings that are changing rapidly

48
Q

What is a StringBuffer?

A
  • mutable
  • synchronized
  • slower
49
Q

What is serialization?

A

is the process where java objects are converted to bytestreams