{"id":8569,"date":"2019-01-02T13:18:11","date_gmt":"2019-01-02T07:48:11","guid":{"rendered":"https:\/\/www.monsterindia.com\/career-advice\/top-20-most-frequently-asked-java-interview-questions-8569\/"},"modified":"2023-07-21T17:55:42","modified_gmt":"2023-07-21T12:25:42","slug":"most-frequently-asked-java-interview-questions","status":"publish","type":"post","link":"https:\/\/www.foundit.sg\/career-advice\/most-frequently-asked-java-interview-questions\/","title":{"rendered":"Top 20 Most Frequently Asked Java Interview Questions"},"content":{"rendered":"<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><img loading=\"lazy\" decoding=\"async\" style=\"margin-right: auto;margin-left: auto\" src=\"http:\/\/media.monsterindia.com\/cmsimages\/1569403076.jpg\" alt=\"Top 20 most frequently asked Java Interview Questions\" width=\"626\" height=\"417\" \/><\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Every one of us has heard of Java even though we may not know exactly what it means or does. And this is because of the huge number of applications of this programming language. Java finds its use in games, desktop applications, and mobile systems among many others. And if you are <a title=\"seeking a job in the IT industry\" href=\"https:\/\/www.monsterindia.com\/it\/\">seeking a job in the IT industry<\/a>, it is almost imperative that you have a basic understanding of Java.<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Here are 20 of the most frequently asked basic Java interview questions and answers, that can help you prepare for an interview regardless of which language you are proficient in.<\/span><\/p>\n<ol style=\"text-align: justify\">\n<li><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>What do you think are the advantages of using Java?<\/strong> <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Java is a high-level object-oriented programming language used for developing games, device systems, and applications. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">It is secure, fast, reliable, portable and platform independent. <\/span>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>2. What do you understand by Object and Class?<\/strong> <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">An object is understood as a collection of methods and classes which represent its state and executes operations. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">A class is used to define new types of data which in turn is used to create objects. <\/span><\/p>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>3. What are JVM, JDK, and JRE?<\/strong> <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">&bull; JVM (Java Virtual Machine) offers the runtime environment for codes to be executed. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">&bull; JRE (Java Runtime Environment) is the collection of files needed during runtime by JVM. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">&bull; JDK (Java Development Kit) is needed to write and execute a program and contains the JRE with necessary development tools. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">4. What is meant by looping? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Loops are used to repeatedly execute a certain statement or block of statements. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">They are of three types- For Loops, While Loops and Do While Loops. <\/p>\n<p><\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>Did you know:<\/strong> <a title=\"Java Developer Jobs\" href=\"https:\/\/www.monsterindia.com\/search\/java-developer-jobs\" target=\"_blank\" rel=\"noopener\">Java Developer Job<\/a> is the 2<sup>nd<\/sup> best job in the US according to Glassdoor&rsquo;s 2020 list of <a href=\"https:\/\/www.glassdoor.com\/List\/Best-Jobs-in-America-LST_KQ0,20.htm\" target=\"_blank\" rel=\"nofollow noopener\">50 Best Jobs in America<\/a>.<\/span><\/p>\n<hr \/>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>5. What is the difference between Overloading and Overriding?<\/strong> <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">When you have two methods of the same name but having different properties, the case is called Overloading. On the other hand, Overriding refers to a situation where two methods with the same name and properties occur, but the two occurring in a parent and child class respectively. <\/span><\/p>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>6. What is Inheritance?<\/strong> <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Inheritance allows you to let a derived class acquire the methods from a base class. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">7. Is it possible to restrict Inheritance? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Yes, it is. You can restrict Inheritance by: <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">a. Using the final keyword. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">b. Making the method final. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">c. Using private constructor. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">d. Using (\/\/) Javadoc comment. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">8. What do you mean by Content Negotiation? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Content negotiation occurs between you as a user and the host server. For instance, when you make an HTTP request you receive your result in different languages and formats, and you can specify what content you will accept back from the host in a negotiation of the type of content shared. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">9. What is WORA? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">WORA or Write Once Read Anywhere, is the property of a language to run on any platform. Java is allowed this property due to its bytecode nature. This is midway between machine code and source code and is thus not platform specific. <\/span><\/p>\n<p><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><strong>10. What is the function of ClassLoader?<\/strong> <\/span><br \/><span style=\"font-size: 12pt\"><span style=\"font-size: 12pt\"><span style=\"font-family: verdana,geneva,sans-serif\">You can use ClassLoader to load class files before running the java program. <br \/><\/span><span style=\"font-family: verdana, geneva, sans-serif\"><br \/><\/span><\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"font-size: 12pt\"><span style=\"font-family: verdana,geneva,sans-serif\"><strong>You may also like:&nbsp;<\/strong> <a title=\"Tips to Unlock the Interview Process for Java Jobs\" href=\"https:\/\/www.monsterindia.com\/career-advice\/tips-to-unlock-the-interview-process-for-java-jobs-at-infosys\/\" target=\"_blank\" rel=\"noopener\">Tips to Unlock the Interview Process for Java Jobs<\/a><\/span><\/span><\/p>\n<hr \/>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\"><br \/>11. What are static methods and static variables? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">They are methods and variables shared by all the objects in a class. Their static nature is a character of the class and not the object itself. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">12. What do you understand by the Object-Oriented Paradigm? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">When your programming paradigm is dependent on objects containing data with methods defined within the class to which they belong, it is referred to as Object Oriented Paradigm. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">13. Is there a difference between Object Oriented and Object-Based language? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Object Oriented languages such as Java and C++ follow all the concepts of an Object Oriented Program and do not have inbuilt objects. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Object-Based languages like JavaScript do not follow all OOPs concepts-such as inheritance-and do have I built objects. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">14. What is the function of a constructor? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">You can use constructors to initialize the state of any object. When you create a new object using a new keyword, a default constructor is invoked. This must have a name similar to the class name. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">15. How do you use &lsquo;this&rsquo; keyword? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">You can use &lsquo;this&#8217; to refer to a current object, invoke the current class method or class constructor. You can also pass it on as an argument into your methods or constructors. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">16. What is aggregation? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">It is a type of weak relation you can create between two classes, where one contain references to another class contained within it. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">17. What is the purpose of composition? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">You can use composition to hold the reference of one class within another class, and in this case, the contained object cannot exist without the class containing it. It is a type of aggregation. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">18. What is annotation? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">Annotation is a tag you use to symbolize metadata that represents your class, interface, and fields among others. <\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">They are used by the compiler and the JVM and don&rsquo;t directly influence the operations. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">19. What is enumeration? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">It is an interface you can use to access original data structure from which the enumeration is obtained. <\/span><\/p>\n<p><span style=\"font-size: 12pt\"><strong><span style=\"font-family: verdana,geneva,sans-serif\">20. What is the function of Synchronized Block? <\/span><\/strong><\/span><br \/><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\">While its scope is smaller than method, you can use it to lock an object for each shared resource.<\/span><span style=\"font-family: verdana,geneva,sans-serif;font-size: 12pt\"><br \/><\/span><\/li>\n<\/ol>\n<p><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><strong>Looking for&nbsp;Java Jobs in top cities? Click at the links below:<\/strong><\/span><\/p>\n<ul>\n<li style=\"text-align: justify\"><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><a title=\"Java&nbsp;Jobs in&nbsp;Chennai\" href=\"https:\/\/www.monsterindia.com\/search\/java-jobs-in-chennai\" target=\"_blank\" rel=\"noopener\">Java&nbsp;Jobs in&nbsp;Chennai<\/a><\/span><\/li>\n<li style=\"text-align: justify\"><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><a title=\"Java&nbsp;Jobs in Mumbai\" href=\"https:\/\/www.monsterindia.com\/search\/java-jobs-in-mumbai\" target=\"_blank\" rel=\"noopener\">Java&nbsp;Jobs in Mumbai<\/a><\/span><\/li>\n<li style=\"text-align: justify\"><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><a title=\"Java&nbsp;Jobs in Gurgaon\" href=\"https:\/\/www.monsterindia.com\/search\/java-jobs-in-gurgaon\" target=\"_blank\" rel=\"noopener\">Java&nbsp;Jobs in Gurgaon<\/a><\/span><\/li>\n<li style=\"text-align: justify\"><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><a title=\"Java Jobs in&nbsp;Pune\" href=\"https:\/\/www.monsterindia.com\/search\/java-jobs-in-pune\" target=\"_blank\" rel=\"noopener\">Java Jobs in&nbsp;Pune<\/a><\/span><\/li>\n<li style=\"text-align: justify\"><span style=\"font-family: verdana, geneva, sans-serif;font-size: 10pt\"><a title=\"Java Jobs in Delhi\" href=\"https:\/\/www.monsterindia.com\/search\/java-jobs-in-delhi\" target=\"_blank\" rel=\"noopener\">Java Jobs in Delhi<\/a><\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: verdana, geneva, sans-serif;font-size: 12pt\">More Resources : <a title=\"Job vacancies in Chennai\" href=\"https:\/\/www.monsterindia.com\/search\/jobs-in-chennai\" target=\"_blank\" rel=\"noopener\">Job vacancies in Chennai<\/a> | <a title=\"Job vacancies in Agra\" href=\"https:\/\/www.monsterindia.com\/search\/jobs-in-agra\" target=\"_blank\" rel=\"noopener\">Job vacancies in Agra<\/a> | <a title=\"Resignation format\" href=\"https:\/\/www.monsterindia.com\/career-advice\/resignation-letter-samples-writing-guide\/\" target=\"_blank\" rel=\"noopener\">Resignation format<\/a> | <a title=\"Java Interview questions for 5 years Experience\" href=\"https:\/\/www.monsterindia.com\/career-advice\/top-20-java-interview-questions-answers-for-5-to-6-years-experience\/\" target=\"_blank\" rel=\"noopener\">Java Interview questions for 5 years Experience<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every one of us has heard of Java even though we may not know exactly what it means or does. And this is because of the huge number of applications of this programming language. Java finds its use in games, desktop applications, and mobile systems among many others. And if you are seeking a job [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8570,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[147],"tags":[],"class_list":{"0":"post-8569","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-interview-questions"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/posts\/8569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/comments?post=8569"}],"version-history":[{"count":1,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/posts\/8569\/revisions"}],"predecessor-version":[{"id":18920,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/posts\/8569\/revisions\/18920"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/media\/8570"}],"wp:attachment":[{"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/media?parent=8569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/categories?post=8569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.foundit.sg\/career-advice\/wp-json\/wp\/v2\/tags?post=8569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}