General Flashcards

1
Q

Object Oriented Programming (OOP)

A

OOP language follow 4 principles: o Encapsulation : We can hide direct access to data by using private key and we can access private data by using getter and setter method.

Abstraction : It is a process of hiding implementation details and showing only functionality to the user. Abstraction lets you focus on what the object does instead of how it does it. o Inheritance : It is used to define the relationship between two classes. When a child class acquires all properties and behaviors of parent class known as inheritance. Child class can reuse all the codes written in parent class. It provides the code reusability. o

Polymorphism : It is an ability of object to behave in multiple form. The most common use of polymorphism is Java, when a parent class reference type of variable is used to refer to a child class object. § E.g.: WebDriver driver = new ChromeDriver(); We use method overloading and overriding to achieve Polymorphism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is immutable?

A

Immutable means that once the constructor for an object has completed execution that instance can’t be altered.

This is useful as it means you can pass references to the object around, without worrying that someone else is going to change its contents. Especially when dealing with concurrency, there are no locking issues with objects that never change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Polymorphism?

A

Polymorphism is a very important concept in OOP because; o it enables to change the behavior of the applications in the run time based on the object on which the invocation happens. o by Polymorphism; one object can have different forms Two types à Compile Time which is Static and Run Time Polymorphism which is related with child and parent class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Access modifier and what are the different access modifiers? Difference between them

A

Java provides a number of access modifiers to set access levels for classes, variables, methods, and constructors.

o Visible to the package, the default. No modifiers are needed.

o Visible to the class only (private).

o Visible to the world (public).

o Visible to the package and all subclasses (protected).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Difference between a Constructor and a Method?

A

Constructor doesn’t have a return type and constructor’s name must be same as the class name. o Constructor is called automatically when a new object is created. Constructor is invoked implicitly. o The Java compiler provides a default constructor if we don’t have any constructor. o Constructors are not inherited by child classes * Method have a return and the method’s name may or not be same as the class name o Method is invoked explicitly. o Method is not provided by compiler in any case. o Methods are inherited by child classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Difference between method Overloading and method Overriding?

A

First and most important difference between overloading and overriding is that, o in case of overloading , method name must be the same, but the parameters must be different; o in case of overriding , method name and parameters must be same Second major difference between method overloading and overriding is that; o We can overload method in the same class but method overriding occurs in two classes that have inheritance relationship. We cannot override static, final and private method in Java, but we can overload static, final and private method in Java. In method overloading , return type can be same or different. In method overriding , return type must be same or covariant type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Difference between Set, List and Map in Java?

A

Set, List and Map are 3 important interface of Java collection framework. o List provides ordered and indexed collection which may contain duplication . o Set provides un-ordered collection of unique objects. Set doesn’t allowed duplication . List and Set are both extend collection interface. o Map provides a data structure based on Key Value. Key is always unique, value can be dupl.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Array?

A

An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed. You have seen an example of arrays already, in the main method of the “Hello World!” application. This section discusses arrays in greater detail.
* Each item in an array is called an element, and each element is accessed by its numerical index. As shown in the preceding illustration, numbering begins with 0. The 9th element, for example, would therefore be accessed at index 8.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Difference between Arrays and ArrayLis tin Java?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is thread safe or Synchronized?

A

Thread safety is very important, and it is the process to make our program safe to use in multi-threaded environment, there are different ways through which we can make our program thread safe.
* Synchronization is the easiest and most widely used tool for thread safety.
* JVM guarantees that synchronized code will be executed by only one thread at a time.
* JAVA keyword synchronized is used to create synchronized code and internally it uses locks on Object or Class to make
sure only one thread is executing the synchronized code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Difference between Hashtable and HashMap in Java?

A

There are several differences between HashMap and Hashtable in Java:
* Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as
unsynchronized Objects typically perform better than synchronized ones.
* Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.
* For example; one of HashMap’s subclasses is LinkedHashMap, so in the event that you’d want predictable iteration order
(which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn’t be as
easy if you were using Hashtable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How would you handle Exception in JAVA?

A

I would use try-catch-finally approach to handle the Exception
* 1- I would put my code that might generate an exception inside a try-catch block. With try-catch block I can rethrow an
exception or try to perform my recovery steps. Also, If needed I can use multi or Union Catch blocks
* 2- I can also use throws keyword. BUT it does mean that anyone that calls my method now needs to handle it too!
* 3- Another way is AutoCloseable: When we place references that are AutoCloseable in the try declaration, then we don’t
need to close the resource ourselves. We can still use a finally block, though, to do any other kind of cleanup we want. try- with

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

TreeSet vs TreeMap

A

TreeSet: Can contain only unique values - is sorted in ascending order
* TreeMap: can contain only unique keys. - keys are sorted in ascending order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

final vs finalize v sfinally?

A

final a keyword and used to apply restrictions on class, method and variable.
o final Class
o final Method
o final Variable value
CAN’T be Inherited CAN’T be Overridden CAN’T be changed.
* finally a block and used to place important code, it will be executed whether exception handled or not
* finalize a method and used to perform clean-up processing before Object is Garbage collected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Difference between RuntimeException and CheckedException in Java?

A

Exception are divided in two categories Runtime (unchecked) Exception and CheckedException.
* Main difference between RuntimeException and CheckedException is that, it is mandatory to provide try-catch to handle
CheckedException while in case of RuntimeException is not mandatory.
* Some of the most common Exception like NullPointerExceptio, ArrayIndexOutOfBound, ClassNotFoundException,
IOException.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Difference between throw and throws in Java?

A

throw and throws are two keywords related to Exception feature of Java programming language.
* throw keyword is used to throw an exception explicitly, on the other hand, throws keyword is used to declare an exception
which means it works similar to the try–catch block.
* If we see syntax wise than throw is followed by an instance of Exception class throws is followed by exception class names.
* throw new ArithmeticException (“Arithmetic Exception”); throws ArithmeticException;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Difference between Object and Class?

A

Class is a blueprint or template which you can create as many objects as you like Object is a member or instance of a class
* Class is declared using class keyword, Object is created through new keyword mainly.
There are many ways to create object in java such as new keyword, newInstance() method, clone() method, factory
method and deserialization. There is only one way to define class in java using class keyword.
* Object is created many times as per requirement. Class is declared once.
* Object is an instance of a class. Class is a blueprint or template from which objects are created.
* Object is a physical entity. Class is a logical entity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

StringBuffer and StringBuilder?

A

The main difference is StringBuffer is synchronized while StringBuilder is non-synchronized. So, StringBuilder can be called simultaneously. And this makes StringBuilder more efficient.
StringBuffer is synchronized, StringBuilder is non-synchronized StringBuilder is more efficient than StringBuffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Important String Methods?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

JavaCollectionFramework

A

List, Set, Map

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Do you know type casting? What is casting?

A

Auto-boxing and Unboxing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the difference between pass-by-value and pass-by-reference?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are the advantages of Selenium?

A

Selenium is open source and free to use without any licensing cost
* It supports multiple languages like Java, Ruby, Python, C#…
* It supports multi-browser testing
* It has a good amount of resources and helping community
* It supports many operating systems like Windows, Mac, Linux …
* Interact with the web application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are the disadvantages of Selenium?

A

Selenium supports only web-based applications, does not support windows-based application
* No built-in reporting tool, it needs third party tools for report generation activity
* Cannot work with graphics, captchas, barcodes, shapes
* It does not support file upload facility.
* Hard to master, requires developer level knowledge
* Hard to write good locators
* Hard to synchronize

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What types of testing you automate with Selenium?

A

functional tests (positive/negative, UI)
* smoke tests
* regression tests
* integration tests
* end to end testing
* data driven

26
Q

Implicit Wait vs Explicit Wait?

A

Implicit wait is a wait which waits for a specified time while locating an element before throwing
“NoSuchElementException”. As by default selenium tries to find elements immediately without any wait. So, it is good
to use implicit wait. This wait applied to all elements of the current driver instance.
* Explicit wait is a wait which is applied to a particular webelement until the ExpectedCondition specified is met.
* Implicit wait is simply; if condition is met before the timeout, it will continue to next step, if condition is not met within
timeout throw “No Such Element” exception.
* Explicit wait sometimes we need to wait for a certain event/condition such as element is visible, clickable, enabled….

27
Q

What is Xpath?

A
28
Q

How do you handle dynamic elements?

A
29
Q

How can we move to parent element using xpath?

A
30
Q

Difference between close() and quit() command?

A
31
Q

What is the key class in Selenium?

A
32
Q

What if there is a dynamic popup that comes up randomly

A

Use try/catch with alert

33
Q

What is Thread.sleep()?

A

Slows down selenium to catch up
* Throws exception so must handle it or throw it

34
Q

Why we get NoSuchElementException?

A
35
Q

How you handle js alerts? How you handle browser pop ups?

A
36
Q

What is the difference between driver.get() and driver.navigateto() ?

A

driver.get()àTo open an URL and it will wait till the whole page gets loaded
* driver.navigateto()àTo navigate to an URL and it will not wait till the whole page get loaded

37
Q

How to handle frames in Selenium?

A
38
Q

findElement vs findElements?

A
39
Q

How to handle multiple windows/tabs?

A
40
Q

How to find all links in the page?

A
41
Q

Difference between isDisplayed(),isEnabled(). And isSelected() method in selenium WebDriver?

A
42
Q

How to DragAndDrop?

A
43
Q

How to use actions class?

A
44
Q

What is the syntax for double click action ?

A
45
Q

File download and upload

A
46
Q

What exceptions do you know in Selenium?

A
47
Q

hard assert VS soft assert

A
48
Q

Tell me more about Cucumber, how did you guys decide to start using Cucumber ?

A
49
Q

Tell me what are the most important things in Cucumber, what makes it unique ?

A
50
Q

How to see your reports in cucumber?

A
51
Q

What is Gherkin?

A
52
Q

What does @CucumberOptions do?

A
53
Q

What are Hooks in cucumber?

A
54
Q

How do you take screenshots in cucumber?

A
55
Q

What is ScenarioOutline? vs Scenario?

A
56
Q

annotations - priority

A
57
Q

How does your framework generate reports?

A
58
Q

How does the FEATURE FILE WORK?

A
59
Q

What is test base Class ? and How do you implement in your framework ?

A
60
Q

How to rerun the failed tests again in Cucumber?

A