Post

Interview_GC/StringBuilder/JVM/Overloading/Overriding/Abstract/Interface/Generic

βœ… Garbage Collection?

Garbage collection

When Java is run on JVM, manage heap
Stop the world, major GC

πŸ’‘ https://soheeparklee.github.io/posts/JAVA_JVM/#%EF%B8%8F-garbage-collector-1

String Builder πŸ†š String Buffer

Difference between stringbuilder and stringbuffer?

같은점: mutation, APIs like append()
⭐️ 참고둜, string is immutable
λ‹€λ₯Έμ :

  • String Builder: synchronization ❌, fast in single thread
  • String Buffer: synchronization ⭕️, multithread

πŸ’‘ https://soheeparklee.github.io/posts/JAVA_library/#-string-class

βœ… Memory in JAVA

How is JVM memory?
>

  • method area: (class loaded) static, method, final
  • heap: (runtime) instance, array
  • JVM stack: (compile) local variable, parameter
  • PC register: (thread created)
  • native method stack: not java

πŸ’‘ https://soheeparklee.github.io/posts/JAVA_JVM/#-jvm-runtime-data-area-%EC%A0%80%EC%9E%A5

Overloading πŸ†š Overriding

Overloading and Overriding?

βœ”οΈ Overloading:

  • method name 🟰
  • parameter βœ–οΈ
  • return type βœ–οΈ
  • when need several


βœ”οΈ Overriding:

  • method name 🟰
  • parameter 🟰
  • return type 🟰
  • need inheritence from parent

πŸ’‘ https://www.geeksforgeeks.org/difference-between-method-overloading-and-method-overriding-in-java/

Abstract class πŸ†š Interface

both used for abstraction

Screenshot 2024-08-07 at 13 19 58

βœ”οΈ Abstract class

  • extends
  • cannot be instantiated directly, serves as blueprint for other classes
  • class can inherit from only one abstract class
  • method, properties can have any access modifier
  • can have variables
  • need to have minimum one abstract method

βœ”οΈ Interface

  • implements
  • set of methods a class must implement
  • class can inherit multiple abstract class
  • method, properties: public
  • no variables
  • inheriting class should override all interface methods

πŸ’‘ https://www.geeksforgeeks.org/difference-between-abstract-class-and-interface-in-java/

βœ… Generic

  • parameterized types
  • allow type to be a parameter to method, class, interface
  • have predefined type
  • Inside <>, only reference type(class, interface, array) is possible.
  • To use primitive types, use wrapper

βœ… Access Modifier

  • public
  • protected: inherited
  • default: same class, same package
  • private

https://soheeparklee.github.io/posts/JAVA_accessmodifier/

Vector πŸ†š Arraylist?

Vector

Synchronized.
If one thread is working with vector, other thread cannot have vector

ArrayList

Unsynchronized
several thread can work on arraylist

βœ… Serialization?

JSON ➑️ Java, visa versa

πŸ’‘ https://soheeparklee.github.io/posts/l-serialization/

This post is licensed under CC BY 4.0 by the author.