What have you done till now as part of your IT experience?
This is an open-ended question where you should provide a
summary of your IT experience, focusing particularly on your QA and SDET roles.
Mention the kind of projects you've worked on, technologies used, testing
methodologies implemented, challenges faced, and how you've overcome them. This
would also be a good place to highlight any achievements or significant
contributions.
Do you know OOPs concepts and a framework where and how you have implemented it?
Yes, I'm familiar with OOP concepts, which include
inheritance, encapsulation, polymorphism, and abstraction. In my previous
project, we used the Selenium WebDriver framework for automating our tests,
which heavily leans on OOP. I've created classes for each module in the
application and used inheritance to reuse methods across classes. Encapsulation
was used to keep data safe, while polymorphism allowed us to implement method
overloading and overriding, thus enhancing the versatility of our testing
scripts.
Can we declare a private class?
In Java, we cannot declare a top-level class as private.
Only nested classes can be private. A private class is a class declared within
another class with the private keyword and can only be accessed from within the class where it is declared.
What is the difference between == and equals?
In Java, "==" is a reference comparison operator,
i.e., it checks if both objects point to the same memory location or not. On
the other hand, "equals()" method checks the equality of two objects'
contents.
How is the string immutable?
In Java, Strings are immutable which means once a String
object is created it cannot be changed. This is because when we try to alter
their values, another object is created in the pool. The original object has not
changed at all. This is advantageous from a security perspective because
parameters are typically represented as strings and immutable objects.
Where do strings get stored and where does the reference get stored?
In Java, Strings are stored in a special area of heap memory
called the String Constant Pool. This is to facilitate reusability and
efficient memory utilization. The reference to the string, however, is stored
on the stack, if it's a local variable.
Can you please explain with reference the memory location of how the string is immutable?
When a string is created in Java, it gets stored in the
String pool which is located in the heap memory. For example, if we create a
string String str1 = "Hello"; a string "Hello" will be
created in the String pool and str1 will be a reference to it. Now if we try to
change str1 like str1 = str1 + "World";, what happens is a new string
"HelloWorld" is created in the String pool and str1 now points to
this new string. The original "Hello" string remains unchanged in the
memory, thus demonstrating the immutability of strings in Java.
If you don't want to use the String class then what can be used?
If we don't want to use the String class, we can use other
classes like StringBuilder or StringBuffer. Both classes are mutable,
meaning their contents can be changed. StringBuilder is generally preferred
when thread safety is not a concern because it's faster, while StringBuffer is
synchronized and thus thread-safe.
Difference between String and StringBuffer.
The main difference between String and StringBuffer is that
Strings are immutable while StringBuffers are mutable. This means once a String
object is created, it cannot be changed. If we try to perform any modification,
it results in a new String object. On the other hand, objects created using
StringBuffer can be modified over time. Additionally, StringBuffer is
thread-safe and synchronized, while String is not.
What collections have you used?
I've used various collection types in my projects depending
on the requirements. Some of the commonly used ones include ArrayList for
dynamically resizable arrays, HashMaps for key-value pair storage, HashSet when
I needed unique elements and LinkedList when frequent insertion and deletion
were involved. I've also used Stack and Queue classes for certain depth-first
and breadth-first algorithms, respectively.