• 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

Why getText() method returns Object instead of String in Protractor?

When using Java, getText() method returns the corresponding text from the element. However in Protractor, getText() method returns Object something like [objectObject].

In Protractor, the getText() method returns a Promise. We need to resolve this in order to get the text.

Syntax:

element.getText().then(function (text)
{ 
    console.log(text); 
});

How do you verify tooltip text using Protractor?

We can verify tooltip text using protractor by fetching the value of ‘title’ attribute.

element(by.id("some")).getAttribute("title").then(function(tooltip)
{
    console.log(tooltip);
}

Are inheritance and overriding concept applicable for the constructor in Java?

In java, inheritance and the overriding concept are not applicable for constructors. In other words, if we inherit a class then the constructor of the parent class is not available in child class.

Constructor Overriding is never possible in Java. This is because, Constructor looks like a method but name should be as class name and no return value. Overriding means what we have declared in Super class, that exactly we have to declare in Sub class it is called Overriding.

What is the difference between GET and NAVIGATE in Protractor?

Get: Get method is used to navigate to the given destination.

browser.get("https://www.programsbuzz.com");

Navigate: Navigate method is used to navigate to the given destination.

browser.navigate()

if we want to load a previous page or next page in a browser we can use back and forward.

browser.navigate().back();
browser.navigate().forward();

What is browser.refresh in Protractor?

browser.refresh makes a full reload of the current page and loads mock modules before Angular. Assumes that the page being loaded uses Angular. If you need to access a page which does not have Angular on load, use the wrapped webdriver directly.

driver.navigate().refresh();

How many ways you can create an Object in Java?

There are the five ways to create the object or get the object in java:

1. By using the new operator

Test t = new Test();

2.  By using the newInstance() Method

Test t = (Test)class.forName("Test").newInstance();

3. By using the factory Method

Runtime r = Runtime.getRuntime();
DateFormat d = Dateformat.getInstance();

4. By using the clone() Method

Test t = new Test();
Test t1= (Test)t.clone();

5. Bu using the deserialization

FileInputStream fis = new FileInputStream("Vinay");
ObjectInputStream obj = new ObjectInputStream(fis);
Dog d = (Dog)obj.readObject();

Not:- There is another way to create the object in Java but this is not standard, it is applicable only for the String

String s = "Vinay";

What will be the output of below Java code?

Example Code: 

public class Test
{
    int i =10;

    public static void main(String[] args)
    {
        System.out.println(i);
    }
}

Output: Error, Cannot make a static reference to the non-static field i.

Subscribe to