No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project <project-name>: Compilation failure No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? Solution Go to Windows –> Preferences –> Java […]
Difference between Class.forName() and newInstance() in java
Difference between Class.forName() and newInstance() in java Class.forName() returns the Class-Type for the given name. Means that it will return reference to a class and load the available all static blocks not instance methods. if you are interested only in…
What is the difference between Static Block and Constructor placed in a class?
What is the difference between Static Block and Constructor placed in a class? Static Block Static block of a java class executes for only one time when JVM loads the class irrespective of whether object is created for class…
Most Important HashMap Interview Questions and Answers
In this post I am sharing most important HashMap interview questions along with answers. Java collections package is java.util, this is the most important package and used frequently in most of the projects. What are the methods required for an…
Explain with example to describe when to use abstract class and interface?
Explain with example to describe when to use abstract class and interface? Consider a scenario where all Cars will have 4 tyres and other features can be different. In this case any subclass of Car has to have 4 tyres.…
How can we call the garbage collector?
How can we call the garbage collector? Garbage collector is automatically invoked when the program is being run. It can be also called by calling gc() method of Runtime class or System class in Java
Which algorithm is used by garbage collector?
Which algorithm is used by garbage collector Garbage collector uses many algorithms but the most commonly used algorithm is mark and sweep.
Java compiler version and project facet selected java version not matching. So we need to change java project facets version according java compiler. Solution Change java project facets java version according java compiler. Select Project –> Right Click –> Project Facets –> Select version in version drop down.
Probably you are using java 8 and the other computer is using java 7. Java requires references to variables from inner classes to be final variables. Java 8 will make them effectively final if you don’t reassign. Probably you are using java 8 and the other computer is using java 7. Java requires references to […]
Static Import This concept is introduces in 1.5, According to static import, improves readability of the code. But According to world wide experts, static import reduces readability and increases the confusion of the code. Hence if there is no specific requirement, it is not recommended to use static import. When we are using static import, […]
Evaluation Order of Java Operand Before applying any operator, all the Operands should be evaluated from left to right.
Precedence Of Java Operators Uniary Operators :- [ 1st level [ ], x++, x– ], [ 2nd level ++x, –x, ~, ! ], [ 3rd level new, <type> ]. Arithmetic Operators:- *, /, %, +, – . Shift Operators:- >>, >>>, << . Comparison Operators:- <, <=, >, >=, instance of, == . Bitwise Operators:- […]
New Operator New operator can be used for the creation of Object. Note:- There is no delete operator in java, Destruction of useless Objects will take care by Garbage Collector.
The only ternary operator available in java is conditional operator. int a = ( 10<20 ) ? 30 : 40 ; System.out.println( a) ; // 30 Nesting of conditional operator is also allowed in java. int x = ( 100>200 ) ? 10 : ( (1000>3000) ? 20 : 30 ) ; System.out.println( x) ; […]
Assignments The following is the list of all possible compound assignment operator. + = & = % = – = | = >>> = * = ^ = << = / = >> = In the case of compound assignment operator, the required type casting is performed automatically by the compiler. byte b = 20 […]
Instance Of Operator Syntax:- t instanceof x t ==> Object / Obj reference. x ==> class name / interface Ex:- Thread t = new Thread ( ) ; System.out.println ( t instanceof Thread ) ; // true System.out.println ( t instanceof Object ) ; // true System.out.println ( t instanceof Runnable ) ; // […]