Showing posts with label webdriver interview questions. Show all posts
Showing posts with label webdriver interview questions. Show all posts

Part 10

46 : What is Polymorphism?
Answer : Polymorphism is ability using which we can create reference variables or methods which behaves differently in different programmatic context. Best example of polymorphism is human. We behaves differently with different people in different environment. Our behavior will be different when we meet to boss and meet to friend. Read more on Polymorphism in java.

47 : What is the advantages of Polymorphism?
Answer : Main advantage of polymorphism is code reusabilty. You can dynamically supply different implementations through polymorphism. So it will reduce your work volume in terms of handling and distinguishing various objects.

Part 9

41 : In java, What is return type of main method?
Answer : Main method doesn't have any return type. It is void.

42 : Can We Overload main method in java?
Answer : Yes, Java class can have any number of main methods so it is possible to overload main method. But when you run program, It will not execute overloaded main method. Always It will execute only public static void main(String[] args) method.

Part 8

36 : What is the difference between the Constructor and Method?
Answer : Main difference between the Constructor and Method is as bellow.

Constructor :
  1. Name of the constructor must be same as class name.
  2. Constructor must not have any return type.
  3. It is used to initialize the state of an object.
  4. It is not possible to call constructor directly. Constructors called implicitly when the new keyword creates an object.
Method :
  1. Method name can be any.
  2. Method must have return type.
  3. It is used to expose behavior of an object.
  4. Methods can be called directly.
Read more on Constructor and Method.

Part 7

31 : What is default value of local variable.
Answer : There is not any default value of local variable. You must have to initialize it. View more details on local variables in java.

32 : Java support constructor inheritance?
Answer : No, Constructor inheritance is not supported in java. View more details on constructor in java.

Part 6

26 : What is local variable in java?
Answer : Local variable is declared inside method or constructor and it is limited for that method or constructor only. View more detail on local variable in java.

Local Variable Example :
public class JavaVariable {

 public void Calc() {
  // Local Variables.
  int sum;
  int item1 = 5;
  int item2 = 7;
  sum = item1 + item2;
  System.out.println("Sum is : " + sum);

 public static void main(String args[]) {
  JavaVariable j = new JavaVariable();

Part 5

21 : Explain System.out.println();

Answer :
  • System : is a final class in  java.lang package.
  • out : is a static member of system class. It is an instance of This stream is already open and ready to accept output data.
  • println : is a method of .It is an overloaded method.

Part 3

11 : Why main method is static?

Answer : As we know, We can access static stuff without creating object of class. Because of static keyword with main method, Java virtual machine can directly call it without creating object of class. This way it will provide kind of root to start execution of program.

12 : What is method overloading?

Answer : Method overloading is ability to create multiple methods with same in same class but with different signatures (different input parameters and types). Method names will be same but parameters will be different for all overloaded methods.

Part 2

6 : What is the difference between static and not static variable?

Answer : Main differences are as bellow.
  • Static variables are preceded by static keyword. For non-static variable, there is not any preceding keyword.
  • Memory is allocated for static variables at the time of class loading. Memory is allocated to non- static variables whenever an object is created.
  • Memory is allocated only once to static variables on class loading. Memory is allocated multiple time whenever a new object is created to non-static variables.
  • Static variable example : Collage name of students, Company name of employees..
READ MORE about static and non-static stuff.

7 : What is the difference between static and not static(Instance) method?

Answer : Difference between static and non static method is as bellow.
  • Method declared with static keyword is static method. If Method declared without static keyword then it is instance method.
  • No need of object to call static methods. Object needed to call instance method.
  • Can not access non static stuff inside static methods directly. Opposite to it, We can access static and non static stuff directly inside instance method.
READ MORE detail on static and non-static stuff.


1 : What is object in java?

Answer : Object Is an Instance of class and it has its own state and behavior. In real world we can say, Dog is object of Animal class which have different state like breed, color, name, hungry, etc and behavior  like wagging tail, fetching, barking etc.

2 : What is class?

Answer : A class is the blueprint or we can say template from which individual objects are created.

Part 23

108 : I wants to pass parameter In software test case through testng.xml file. How can I do It?

Answer : You can use <parameter> node under <test> node In testng.xml file with parameter name and value. Then you can use @Parameters annotation with parameter name In your test case of software web application. VIEW USAGE OF @PARAMETER ANNOTATION.

Part 22

103 : How to customize Firefox browser profile for webdriver software test?

Answer : You can do It In two different ways.
  1. You can create your desired firefox browser profile before running software automation test and then you can use It In your selenium webdriver software test. VIEW EXAMPLE.
  2. You can customize your firefox browser profile run time before launching webdriver's Firefox browser Instance. VIEW EXAMPLE.

Part 21

98 : Do you know any external API name using which we can read data from excel file?

Answer : 
  • We can use jxl API (Java Excel API) to read data from excel file. VIEW EXAMPLE
  • We can use one more powerful API known as Apache POI API to read and write data In excel file. I have created data driven framework using Apache POI API. You can VIEW DATADRIVEN FRAMEWORK CREATION TUTORIALS step by step.

Part 20

93 : Tell me the class name using which we can generate Action chain.

Answer : The WebDriver class name Using which we can generate Action chain Is "Actions". VIEW USAGE OF ACTIONS CLASS with practical example on how to generate series of actions to drag and drop element of software web application.

Part 19

88 : In XPath, I wants to do partial match on attribute value from beginning. Tell me two functions using which I can do It.

Answer : We can use bellow given two functions with XPath to find element for software web page using attribute value from beginning.
  1. contains()
  2. starts-with()

Part 7

31 : Can you tell me the names of different projects of selenium software automation testing tool?
Answer : At present, Selenium software automation testing tool has four different projects as bellow.
  • Selenium IDE : It Is Firefox add-on which allows you to record and playback your software web application's tests In Firefox browser.
  • Selenium RC : It Is software web application automation tool which allows you to write your tests In many different programming languages.

Part 6

26 : Can we automate desktop software application's testing using selenium WebDriver?
Answer : No. This Is the biggest disadvantage of selenium WebDriver API. We can automate only web and mobile software application's testing using selenium WebDriver.

27 : Can you tell me the alternative driver.get() method to open URL In browser?

Part 5

21 : How does selenium RC software testing tool drive the browser? 
Answer :
When browser loaded In Selenium RC, It ‘injected’ javascript functions into the browser and then It Is using javascript to drive the browser for software application under test.

Part 4

16 : How to press ENTER key button on text box In selenium webdriver?
Answer : To press ENTER key using selenium WebDriver software automation tool, We need to use selenium Enum Keys with Its constant ENTER as bellow.

17 : How many types of waits available In selenium WebDriver

Part 3

11 : Can you tell me the syntax to open/launch Firefox browser In WebDriver software testing tool?
Answer : We can open new Mozilla Firefox browser Instance using bellow given syntax In WebDriver software testing tool.

System.setProperty("webdriver.gecko.driver", "D:\\Selenium Files\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();

Part 2

6 : What are the benefits of automation testing.
Answer : We can get bellow given benefits If automate our software testing process.
  • Fast Test Execution : Manual software testing process Is time consuming. Automation tests are faster and takes less time to execute tests compared to manual test execution.