Hello Friends, In this Blog Post I am going to let you know about a few more interview questions of core java related to methods in java.
Core java interview questions cover all the important questions of the topics mentioned above.
These core java interview questions are a great help to remember all the important highlights and important topics from each java chapter.
These interview questions will surely help to understand a few very confusing concepts in java.
What are instance methods?
Instance methods are the methods that act on the instance variables of the class. To call the instance methods, we should use the form: object name. method name().
What are static methods?
Static methods are the methods that do not act upon the instance variables of a class. Static methods are declared as ‘static’.
What is the difference between instance variable and class variable(static variable)?
An instance variable is a variable whose separate copy is available to each object. A class variable is a variable whose single copy in memory is shared by all objects.
Instance variables are created in the objects on heap memory. A class variable is stored in the method area.
Why instance variables are not available to a static method?
After executing the static method. JVM creates the objects. So the instance variable of the objects is not available to static methods.
Is it possible to compile and run a java program without writing the main() method?
Yes, it is possible by using a static block in the java program.
How are the objects are passed to the methods in java?
Primitive data types, objects, even object references – everything is passed to a method using the ‘pass by value’ or ‘call by value’ concept. This means their bit-by-bit copy is passed to the methods.
What is the factory method?
A factory method is a method that creates and returns an object to the class to which it belongs. A single factory method replaces several constructors in the class by accepting different options from the user. While creating the object.
So this was all about the Core java interview questions on this topic.
These Core java interview questions could be a great help in your college viva, academic study, and any job interview.
In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.
Hope! you would have enjoyed this post about Core Java Interview Questions Part 9/ methods in java.
Please feel free to give your important feedback in the comment section below.
Have a great time!