☕️JAVA Language Community
2.91K subscribers
144 photos
7 videos
31 files
42 links
☕️ Software, IT, Java, news
💻 IT highlights
🎯 AI update
🖥⌨️🖱
Download Telegram
#Java_Interview_Question

127) What is serialization?

Serialization is a process of writing the state of an object into a byte stream.It is mainly used to travel object's state on the network.

@javaCode☕️
☕️JAVA Language Community
Photo
#Java_Interview_Question

👉Serialization in Java

Serialization in java is a mechanism of writing the state of an object into a byte stream.

It is mainly used in Hibernate, RMI, JPA, EJB and JMS technologies.

The reverse operation of serialization is called deserialization.

👉Advantage of Java Serialization

It is mainly used to travel object's state on the network (known as marshaling).

@javaCode☕️
☕️JAVA Language Community
#Java_Interview_Question 👉Serialization in Java Serialization in java is a mechanism of writing the state of an object into a byte stream. It is mainly used in Hibernate, RMI, JPA, EJB and JMS technologies. The reverse operation of serialization is called…
👉java.io.Serializable interface

Serializable is a marker interface (has no data member and method). It is used to "mark" java classes so that objects of these classes may get certain capability. The Cloneable and Remote are also marker interfaces.

It must be implemented by the class whose object you want to persist.

The String class and all the wrapper classes implements java.io.Serializable interface by default.

@javaCode☕️
#Java_Interview_Question

👉ObjectOutputStream class

The ObjectOutputStream class is used to write primitive data types and Java objects to an OutputStream. Only objects that support the java.io.Serializable interface can be written to streams.

👉ObjectInputStream class

An ObjectInputStream deserializes objects and primitive data written using an ObjectOutputStream.

@javaCode☕️
#Java_Interview_Question

128) What is Deserialization?

Deserialization is the process of reconstructing the object from the serialized state.It is the reverse operation of serialization.

@javaCode☕️
#Java_Interview_Question

129) What is transient keyword?

If you define any data member as transient,it will not be serialized.

👉more details

▪️Java Transient Keyword

Java transient keyword is used in serialization. If you define any data member as transient, it will not be serialized.

Let's take an example, I have declared a class as Student, it has three data members id, name and age. If you serialize the object, all the values will be serialized but I don't want to serialize one value, e.g. age then we can declare the age data member as transient.

@javaCode☕️
#Java_Interview_Question

130)What is Externalizable?

Externalizable interface is used to write the state of an object into a byte stream in compressed format.It is not a marker interface.

@javaCode☕️
#Java_Interview_Question

131)What is the difference between Serializalble and Externalizable interface?

Serializable is a marker interface but Externalizable is not a marker interface.When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process.

@javaCode☕️
#Java_Interview_Question

132)How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com?

By InetAddress.getByName("192.18.97.39").getHostName() where 192.18.97.39 is the IP address.

@javaCode☕️
#Java_Interview_Question

133) What is reflection?

Reflection is the process of examining or modifying the runtime behaviour of a class at runtime.It is used in:

IDE (Integreted Development Environment) e.g. Eclipse, MyEclipse, NetBeans.
Debugger
Test Tools etc.

@javaCode☕️
#Design_Patterns

#Structural_patterns

#Composite_Design_Pattern

👉Intent

▪️Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

▪️Recursive composition

▪️"Directories contain entries, each of which could be a directory."

▪️1-to-many "has a" up the "is a" hierarchy

@javaCode☕️
#WRK!
Do you want to benchmark your REST APIs.
I recently used WRK alongside with some LUA Scripts to Benchmark my REST APIs has developed in a micro-service project.
I suggest using it. it is faster than jMeter and needing less resources than it.
It is console base tool and you can run it easily on any remote server.
A little tricky to be used efficiently and you need to write LUA scripts for complex benchmarks; for e.g. authentication with your REST end-points and Posting complex JSON as request body and etc.

very Basic Example without LUA:

wrk -t10 -c100 -d10s http://localhost:9090/touraj_ebrahini.html

t: number of threads
c: number of connections
d: duration in seconds

—------------------------------------------------------------------------------------—

Testing with a Simple LUA Script:

wrk -t2 -c4 -d2s -s /opt/luawrk/test.lua http://localhost:9090/touraj/test/restapi/{path variable}

test.lua:

wrk.method = "POST"
wrk.body = "{'num': 24233,'name':'wrk_disp','list': [{'name':'contact1', 'num':234324},{'name':'contact2', 'num':234324}]}"
wrk.headers["Content-Type"]= "application/json"
wrk.headers["Authorization"]= "Basic wrkhdgreheydfgdmanksflol3Kbyedf="
wrk.headers["Cache-Control"]= "no-cache"

@javaCode☕️
#Java
#Spring Boot
#Semantic UI
#Kalah Game

Kalah, also called Kalaha or Mancala, is a game in the mancala family imported in the United States by William Julius Champion, Jr. in 1940.

In youtube you can watch what has been developed for making KALAH game with Java, Spring Boot and Semantic UI.
I suggest Semantic UI as an alternative to Bootstrap that is very light wight, strong and feature-rich.

https://www.youtube.com/watch?v=nAedcao7p64&t=313s

@javaCode☕️