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 the static block of the class , the loading the class only would do , […]
Category: Interview Questions
Java Interview Questions and Answers
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 or not and whether java class is having main method or not. So static block […]
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 object to be used as a key or value in HashMap equals() hashcode() The key […]
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. This is a case where abstract class will be used and a default implementation for […]
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 NarayanaswamyHello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more […]
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. NarayanaswamyHello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my web technologies blog. My specialties are […]
Which part of JVM will allocate the memory for a java program?
Which part of JVM will allocate the memory for a java program? Class loader sub sytem of JVM will allocate the necessary memory needed by the Java program. NarayanaswamyHello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my […]
Why java is suitable for internet?
Why java is suitable for internet? Java is suitable for internet because of two main reasons. It is system independent and hence its programs can run on any type of computer system on internet. It eliminates a lot of security problems for data on internet. NarayanaswamyHello! I am Narayanaswamy founder and admin of […]
What is difference between abstract class and interface?
What is difference between abstract class and interface? Abstract class may or may not be contain abstract methods but a class should be called as abstract when it contains at least one abstract method. It can also contain n numbers of concrete method. Interface can contain only abstract ( non implemented) methods. The abstract […]
What is the difference between static and instance methods?
What is the difference between static and instance methods? Instance method belongs to the instance of a class therefore it requires an instance before it can be invoked, whereas static method belongs to the class itself and not to any class instance so it doesn’t need an instance to be invoked. Instance methods use dynamic […]