Day8. JavaConceptsComparison (Www.yellowcoder.in)
Day8. JavaConceptsComparison (Www.yellowcoder.in)
Java
Concepts
Comparison
Cheat Sheet
www.yellowcoder.in
Public vs Private:
Public methods and fields are accessible from
anywhere, whereas private ones are accessible
only within the same class.
9686945757: Message Here for Full access to Java interview Prep Website
Set vs List:
A set ensures uniqueness of elements, while a
list allows duplicates and maintains insertion
order.
Comparable vs Comparator:
Comparable provides a natural ordering using
compareTo, while Comparator is used for custom
ordering with compare.
Thread vs Runnable:
A thread is an independent execution unit, while
Runnable is a task representation executed by a
thread. www.yellowcoder.in
StringBuilder vs StringBuffer:
StringBuilder is faster and non-thread-safe,
whereas StringBuffer is thread-safe but slower
due to synchronization.
9686945757: Message Here for Full access to Java interview Prep Website
Abstract class vs Concrete class:
Abstract classes cannot be instantiated and are
meant for inheritance, while concrete classes can
be instantiated directly.
Serialization vs Deserialization:
Serialization converts an object to a byte stream,
while deserialization recreates the object from
the byte stream.
HashMap vs TreeMap:
HashMap provides fast key-value lookups with
no order, while TreeMap maintains keys in
sorted order.
www.yellowcoder.in
ArrayList vs LinkedList:
ArrayList is faster for random access, while
LinkedList is efficient for insertions and
deletions.
9686945757: Message Here for Full access to Java interview Prep Website
HashMap vs HashTable:
HashMap is unsynchronized and faster, while
Hashtable is synchronized and thread-safe.
9686945757: Message Here for Full access to Java interview Prep Website
Functional programming vs Object-oriented
programming:
Functional programming focuses on
immutability and functions, while OOP centers
on objects and state.
@SpringBootApplication vs @Configuration:
@SpringBootApplication combines
@Configuration, @EnableAutoConfiguration, and
@ComponentScan, while @Configuration only
defines beans.
9686945757: Message Here for Full access to Java interview Prep Website
@ComponentScan vs @EnableAutoConfiguration:
@ComponentScan scans and registers beans,
while @EnableAutoConfiguration automatically
configures Spring Boot based on dependencies.
@Configuration vs @Bean:
@Configuration defines a class with bean
methods, while @Bean marks a specific method
to produce a bean.
www.yellowcoder.in
@Autowired vs @Qualifier:
@Autowired injects a bean, and @Qualifier
specifies which bean to inject when multiple
candidates exist.
@RestController vs @Controller:
@RestController combines @Controller and
@ResponseBody for REST APIs, while
@Controller handles MVC views.
@RequestMapping vs @GetMapping:
@RequestMapping is versatile for all HTTP
methods, while @GetMapping is specific to GET
requests.
9686945757: Message Here for Full access to Java interview Prep Website
@PathVariable vs @RequestParam:
@PathVariable extracts values from URL paths,
while @RequestParam retrieves query parameter
values.
@PostMapping vs @PutMapping:
@PostMapping creates new resources, while
@PutMapping updates existing ones.
PUT vs PATCH:
PUT replaces the entire resource, while PATCH
modifies specific fields of a resource.
@ExceptionHandler vs @ControllerAdvice:
@ExceptionHandler handles exceptions at the
controller level, while @ControllerAdvice
provides global exception handling.
@Primary vs @Qualifier:
@Primary gives default precedence to a bean,
while @Qualifier explicitly specifies which bean
to use.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
@Async vs @Scheduled:
@Async enables asynchronous execution, while
@Scheduled schedules tasks at fixed intervals.
@Cacheable vs @CacheEvict:
@Cacheable caches results of a method, while
@CacheEvict removes entries from the cache.
application.properties vs application.yml:
application.properties uses key-value pairs, while
application.yml supports hierarchical
configurations.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
Maven vs Gradle:
Maven uses XML for dependency management,
while Gradle uses a more concise Groovy/Kotlin
DSL.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
JDK vs JRE:
JDK is a development kit with tools to create Java
applications, while JRE provides runtime for
executing Java programs.
JVM vs JRE:
JVM runs Java bytecode, while JRE provides
libraries and tools for JVM execution.
Java vs JavaScript:
Java is a statically-typed, object-oriented
language, while JavaScript is a dynamically-typed
scripting language for web development.
Inheritance vs Composition:
Inheritance reuses code through parent-child
relationships, while composition uses object
references for functionality reuse.
9686945757: Message Here for Full access to Java interview Prep Website
Polymorphism vs Overloading:
Polymorphism allows method behavior to vary in
subclasses, while overloading defines multiple
methods with the same name but different
signatures.
Encapsulation vs Abstraction:
Encapsulation hides data implementation details,
while abstraction focuses on exposing essential
features without implementation specifics.
Synchronized vs Volatile:
Synchronized ensures thread-safe blocks or
methods, while volatile ensures visibility of
variable changes across threads.
Thread vs Process:
A thread is a lightweight, independent unit
within a process, while a process is a self-
contained execution environment.
www.yellowcoder.in
Runnable vs Callable:
Runnable represents a task with no return value,
while Callable returns a result and can throw
exceptions.
9686945757: Message Here for Full access to Java interview Prep Website
Future vs CompletableFuture:
Future represents a pending result with limited
features, while CompletableFuture provides
extensive methods for asynchronous
programming.
Executor vs ExecutorService:
Executor runs tasks, while ExecutorService
manages and controls task execution with
features like thread pools.
ForkJoinPool vs ThreadPoolExecutor:
ForkJoinPool efficiently handles recursive tasks,
while ThreadPoolExecutor manages thread
pooling for varied tasks.
Semaphore vs CountDownLatch:
Semaphore controls access to shared resources,
while CountDownLatch waits for a set number of
threads to complete. www.yellowcoder.in
CyclicBarrier vs CountDownLatch:
CyclicBarrier resets after threads synchronize,
while CountDownLatch counts down to zero and
cannot reset.
9686945757: Message Here for Full access to Java interview Prep Website
ReentrantLock vs synchronized:
ReentrantLock offers advanced locking features
like fairness, while synchronized provides
simpler, implicit locking.
ReadWriteLock vs ReentrantLock:
ReadWriteLock separates read and write locks
for concurrency, while ReentrantLock provides
exclusive access only.
ConcurrentHashMap vs HashMap:
ConcurrentHashMap is thread-safe, while
HashMap is faster but not thread-safe.
CopyOnWriteArrayList vs ArrayList:
CopyOnWriteArrayList is thread-safe and
immutable during iteration, while ArrayList is
faster but not thread-safe.
BlockingQueue vs ConcurrentLinkedQueue:
BlockingQueue supports thread-safe blocking
operations, while ConcurrentLinkedQueue is
non-blocking.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
ArrayBlockingQueue vs LinkedBlockingQueue:
ArrayBlockingQueue is bounded and faster,
while LinkedBlockingQueue can grow
dynamically.
PriorityQueue vs ArrayDeque:
PriorityQueue orders elements by priority, while
ArrayDeque is a double-ended queue without
ordering.
LinkedList vs ArrayList:
LinkedList is better for insertions/deletions,
while ArrayList is faster for random access.
HashSet vs TreeSet:
HashSet is faster and unordered, while TreeSet is
slower but maintains sorted order.
HashMap vs LinkedHashMap:
LinkedHashMap preserves insertion order, while
HashMap does not.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
Hashtable vs ConcurrentHashMap:
Hashtable is synchronized but slower, while
ConcurrentHashMap offers better concurrency.
WeakHashMap vs IdentityHashMap:
WeakHashMap uses weak keys for garbage
collection, while IdentityHashMap uses reference
equality for key comparison.
EnumSet vs HashSet:
EnumSet is optimized for enums, while HashSet
works for any object.
EnumMap vs HashMap:
EnumMap is optimized for enums as keys, while
HashMap works for all objects.
www.yellowcoder.in
9686945757: Message Here for Full access to Java interview Prep Website
Optional vs null:
Optional avoids null by providing a container
object, while null can cause
NullPointerException.
Predicate vs Function:
Predicate evaluates a condition and returns a
boolean, while Function transforms input into
output.
www.yellowcoder.in
Supplier vs Consumer:
Supplier provides a value with no input, while
Consumer accepts input with no return value.
9686945757: Message Here for Full access to Java interview Prep Website
FlatMap vs Map:
FlatMap flattens nested structures, while Map
transforms data one-to-one.
Collectors.toList() vs Collectors.toSet():
toList() collects data into a list, while toSet()
collects into a set ensuring uniqueness.
Collectors.groupingBy() vs Collectors.partitioningBy():
groupingBy categorizes data into multiple groups,
while partitioningBy splits into two groups based
on a condition.
BufferedReader vs FileReader:
BufferedReader reads text efficiently with
buffering, while FileReader reads characters
directly. www.yellowcoder.in
BufferedWriter vs FileWriter:
BufferedWriter writes text efficiently with
buffering, while FileWriter writes characters
directly.
9686945757: Message Here for Full access to Java interview Prep Website
This roadmap pdf is not complete
Message on instagram to
get the complete one !
FOLLOW
@backend.interview.preparation
www.yellowcoder.in
www.yellowcoder.in
Microservice Projects
and
java interview
preparation website
MESSAGE ME
TO GET ACCESS
- START PREPARING TODAY
Download All Roadmap Pdfs From Here(Click)
9686945757: Message Here for Full access to Java interview Prep Website