Java Interview Questions SET-01
Java Interview Questions Set-02 ARRAY
Java Interview Questions Set-03 MAP
Java Interview Question Set-04
What are the access modifiers in Java and their visibility scopes?
Answer:
Java has four access modifiers: public, private, protected, and default (no explicit modifier). Their visibility scope is as follows:
- Public: Visible for all classes.
- Private: Visible only within the same class.
- Protected: Visible within the same package and subclasses.
- Default: Visible within the same package.
Example:
Thread
class and the Runnable
interface. In Java, both "throws" and "try-catch" are mechanisms used for handling exceptions, but they serve different purposes:
- "throws" is used to declare that a method may throw one or more exceptions. It is part of the method signature and indicates that the method does not handle the exception itself but rather passes the responsibility of handling it to the caller or the calling method. When a method declares "throws" for an exception, it means it is not handling the exception and expects the caller to handle it or propagate it further up the call stack. The caller must either catch the exception or declare "throws" in its own method signature.
Example:
equals()
and ==
in Java?equals()
is a method used to compare the content or values of two objects, while ==
is used to compare the references or memory addresses of two objects. Here's an example:How to Sort a Hashmap in Java?
I hope this helps you understand how to loop around arrays, lists, and maps in Java!
Looping around the map:
A map is a data structure that stores key-value pairs. In Java, the java.util.Map
interface is commonly used. Here's an example of looping around a map in Java:
Output:
makefile
John: 25
Alice: 30
Bob: 35
In this example, we create a map called ages
and use the put()
method to add key-value pairs to the map. Then, we use a "for-each" loop with entrySet()
to iterate over each key-value pair in the map. We extract the key and value using the getKey()
and getValue()
methods, respectively, and print them.
Basic Linux Commands for Automation QA
****************************************
SDET Interview Question and Answers
TestNG Interview questions and answers
Jenkins Interview Questions and Answers
Appium Interview Questions and Answers
Selenium Interview Questions and answers
Java Coding Interview Questions and Answers
GIT Interview Questions and Answers
************************************************
✍️AUTHOR: LinkedIn Profile
************************************************
Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session
*************************************************
SeleniumWebdriver Automation Testing Interview Questions:
https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver
API Testing Interview Question Set:
https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html
DevOps Interview Q&A:
https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes
Docker Interview Question Set
https://automationreinvented.blogspot.com/Docker
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign
Java Related Interview Question Set
https://automationreinvented.blogspot.com/search/label/Java
GIT Interview Question Set:
https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html
Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing
Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python
No comments:
Post a Comment