What is POJO in Java?

POJO stands for “Plain Old Java Object” — it’s a pure data structure that has fields with getters and possibly setters, and may override some methods from Object (e.g. equals) or some other interface like Serializable, but does not have behavior of its own.

 

  1. Normal Class: A Java class
  2. Java Beans:

What is Autoboxing in Java

Autoboxing and unboxing are introduced in Java 1.5 to automatically convert the primitive type into boxed primitive( Object or Wrapper class). autoboxing allows you to use primitive and object type interchangeably in Java in many places like an assignment, method invocation etc. If you have been using Collections like HashMap or ArrayList before Java

Read More

Static and dynamic binding in java

Early Late
Compile time Run time
Overloading Overriding
  1. Static binding happens at compile-time while dynamic binding happens at runtime.
  2. Binding of private, static and final methods always happen at compile time since these methods cannot be overridden. When the method overriding is actually happening and the reference of parent type is assigned to the object of child

    Read More

Get jsp response as a string inside servlet

To get jsp response as a string inside servlet is possible by wrapping the HttpServletResponse and overriding getWriter methods.

Servlet

JSP

 

Read More

Sorting HashMap by values in ascending and descending order

The below example shows Java program to sort a Map by values in ascending and descending order, you can see that it’s so easy to sort the Map.

 

Read More

Difference between Java Collection and Collections

collection : A collection(with small ‘c’) represents a group of objects/elements.

Collection : The root interface of Java Collections Framework.

Collections : A utility class that is a member of the Java Collections Framework.

Read More

String vs StringBuffer vs StringBuilder in Java

The String is one of the most important classes in Java and anyone who starts with Java programming uses String to print something on the console by using famous System.out.println() statements. Many Java beginners not aware that String is immutable and final in Java and every modification in String creates a new String object.

Read More

Read Input from User

In Java, there are three different ways for reading input from the user in the command line (console).

1.Using Buffered Reader Class

This method is used by wrapping the System.in (standard input stream) in an InputStreamReader which is wrapped in a BufferedReader, we can read input from the user in the command

Read More

Find Upper Case & Lower Case

Given a string, bellow it shows the boolean condition to find Lowercase characters, Uppercase characters.

 

Read More