• Slider Banner

    Prepare for

    Technical Interview

    Over .1 Million+ Interview Questions for different profiles

    Read More
  • Slider Banner

    Join the

    Programming World

    Learn about top programming languages, tools and frameworks.

    Read More
  • Slider Banner

    Prepare with

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read More

What is return type of TestNG Data Provider?

Data provider returns a two-dimensional JAVA object to the test method and the test method, will invoke M times in a M*N type of object array. For example, if the DataProvider returns an array of 2*3 objects, the corresponding test case will be invoked 2 times with 3 parameters each time.

Example:

/**
   * @return Object[][] where first column contains 'author'
   * and second column contains 'Country'
*/

    @DataProvider(name="SearchProvider")
    public Object[][] getData()
    {
        return new Object[][]
        {
            { "Ram", "India" },
            { "Sham", "UK" },
            { "Mohan", "USA" }
       };
    }

What is API Mocking?

The most common term for creating simulated components is mocking, but others are also used, and partly apply to different things; stubbing, simulation, and virtualization. The basic concept is the same - instead of using an actual software component (an API in our case) – a "replacement" version of that API is created and used instead. It behaves as the original API, but lacks many of the functional and non-functional characteristics of the original component. Which term is applicable depends on the degree to which the mock-up corresponds to the actual API:

  • Stubbing: mostly a placeholder without real functionality
  • Mocking: basic functionality required for a specific testing or development purpose
  • Simulation: complete functionality for testing or development purposes
  • Virtualization: Imulation that is deployed into an operational, manageable and controllable environment

Write a Java Program to convert "Welcome to Java" to "Java to Welcome".

Check below code:

package com.test.strings;

public class StringWords 
{
	public static void main(String args[])
	{
		String s = "Welcome to Java";
		
		String a[] = s.split(" ");
		
		String rev = "";
		
		for(int i = a.length - 1; i >= 0; i--)
		{
			rev = rev + a[i] + " ";
		}
		
		System.out.println(rev);
	}
}

Output: Java to Welcome

What will be the output of below Java code?

Sample Code: 

public  class  A  
{
    public void m1(int ... i)
    {
        System.out.println("Parent class");
    }
}

public class B extends A
{
    public void m1(int i)
    {
        System.out.println("child class");
	}
}

class C
{
    public static void main(String[] args)
    {
        A a = new A();
        a.m1(10);

        B b=new B();
        b.m1(10);

        A a1=new B();
        a1.m1(10);
    }
}

Output:

Parent class

child class

Parent class

How do you click on a menu item in a drop down menu in Selenium?

If that menu has been created by using select tag then we can use the methods selectByValue() or selectByIndex() or selectByVisibleText(). These are the methods of the Select class.

If the menu has not been created by using the select tag then we can simply find the xpath of that element and click on that to select.

Subscribe to