Posts

Showing posts from August, 2024

Serialization in Java

  Sent by Copilot: Serialization in Java is the process of converting an object’s state into a byte stream, which can then be easily saved to a file, sent over a network, or stored in a database. Deserialization is the reverse process, where the byte stream is used to recreate the original object in memory. Why is Serialization Needed? Persistence : Serialization allows you to save the state of an object to a storage medium (like a file or a database) and retrieve it later. This is useful for saving user sessions, game states, or any other data that needs to be preserved between program executions. Communication : Serialization is essential for sending objects over a network. For example, in a client-server application, objects can be serialized and sent from the client to the server and vice versa. Caching : Serialized objects can be stored in a cache to improve performance by avoiding the need to recreate objects from scratch. Real-World Example Consider a  chat application  where me

Deutsche Bank Interview Questions - 2024

  - Write a code Read a JSON file in java and get all objects/array objects from it. - How is Vector different than a List? - Collections vs Collection? - How do you make sure a List is not accessed concurrently? - Are Thread.sleep() and wait method from selenium static? - Can we overload sleep() and wait() methods? - Difference between sleep() and wait() methods - What is Transient in Java? - Explain the whole hierarchy of Collections interface - Is ArrayList thread safe? - How to make a list thread safe? - What is Autoboxing and Unboxing in java? - Wrapper classes in java? - Can we have method implementation inside an Interface? - What is Fail fast in java? - Write a program  Find all pairs of elements in an array whose sum is equal to given number array- {4,5,7,11,9,13,8,12,10,10} given number -20. Eg., O/p: should be: 11,9 8,12, 13,7 10,10 - What is fail fast mechanism in Java - Do you know lambda expressions?

Java OOPs Concept

Image
 

Aggregation and Composition - OOPS

  Sent by Copilot: Sure! Let’s break down the concepts of aggregation and composition in Java with simple examples. Aggregation Aggregation is a type of association where one class contains a reference to another class. It represents a “has-a” relationship but with a weaker bond. The contained object can exist independently of the container object. Example: Consider a  Library  and  Book : Java class Book { String title; String author; Book(String title, String author) { this .title = title; this .author = author; } } class Library { String name; List<Book> books; Library(String name, List<Book> books) { this .name = name; this .books = books; } void displayBooks () { for (Book book : books) { System.out.println( "Title: " + book.title + ", Author: " + book.author); } } } public class Main { public static void main (String[] args)

Core Java Interview Questions

Follow this link:  https://www.javatpoint.com/corejava-interview-questions

Default Constructor in Java

  Sent by Copilot: In Java, a  default constructor  is a constructor that is automatically generated by the compiler if no constructors are explicitly defined in a class. It is a no-argument constructor that initializes the object with default values. What Does the Default Constructor Do? Initialization : The default constructor initializes the object with default values. For primitive data types, these default values are: int ,  short ,  byte ,  long :  0 float ,  double :  0.0 char :  '\u0000'  (null character) boolean :  false For reference types (like objects), the default value is  null . Implicit Creation : If you do not define any constructor in your class, the Java compiler automatically provides a default constructor. Example Let’s look at an example to understand this better: Java class Student { String name; int age; // No explicit constructor defined } public class Main { public static void main (String[] args) { Student student