Author Archives: Amit Jain

What is the use of Abstract modifier in Java

What is the use of Abstract modifier in Java

  What is the use of Abstract modifier in Java An abstract is a modifier applicable to classes and methods but not for variables. Abstract Method Even though we don’t know about implementation still, we can declare a method with abstract modifier i.e. for the abstract method the only declaration is available but not implementation hence abstract declaration should end ...

Read More »

What is final in Java?

What is final in Java?

What is final in Java? Final is the modifiers applicable for classes, methods, and variables.  The main advantage of final keyword is we can achieve security and we can provide the unique implementation. Final keyword improves performance. Not just JVM can cache final variable but also application can cache frequently use final variables. Final variables are safe to share in multi-threading environment without additional ...

Read More »

What is Modifier and what are the applicable Class Modifiers?

What is Modifier and what are the applicable Class Modifiers?

What is Modifier and what are the applicable Class Modifiers? Modifiers are keywords that you add to class, methods, and variables to change their meanings. Java language has a wide variety of modifiers. Access modifiers are a specific part of programming language syntax used to facilitate the encapsulation of components. When a class is declared as public, it is accessible ...

Read More »

What is package and what is the advantage?

What is package and what is the advantage?

What is package and what is the advantage? It is an encapsulation mechanism to group related classes and interface into a single unit, which is nothing but packages. Packages are named in reverse order of domain names, i.e., com.java4us.packageprogram.A Java package is a group of similar types of classes, interfaces, and sub-packages. There are many built-in packages such as Java.lang, awt, javax, ...

Read More »

Difference between normal import & static import?

Difference between normal import & static import?

Difference between normal import & static import? Explain import statement and difference between normal import & static import? To access a class or method from another package we need to use the fully qualified name or we can use import statements. The class or method should also be accessible. Accessibility is based on the access modifiers. Private members are accessible ...

Read More »

How many class can be public in Java Program?

How many class can be public in Java Program?

How many class can be public in Java Program?   A JAVA Program can have any number no class but at most one class can be declared as public. If there is public class then the name of the Java program must be same as public class otherwise we will get compile time error. Based on the Java standards and ...

Read More »