Bird
0
0

Which of the following is the correct syntax to call a method named login from a page object instance loginPage inside a test method?

easy📝 Syntax Q3 of 15
Selenium Java - Page Object Model
Which of the following is the correct syntax to call a method named login from a page object instance loginPage inside a test method?
AloginPage->login();
BloginPage.login();
CloginPage.login;
DloginPage::login();
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java method call syntax

    In Java, methods are called using dot notation with parentheses.
  2. Step 2: Identify correct syntax

    loginPage.login(); uses loginPage.login(); which is correct Java syntax for calling a method.
  3. Final Answer:

    loginPage.login(); -> Option B
  4. Quick Check:

    Java method call = dot + parentheses [OK]
Quick Trick: Call methods with dot and parentheses in Java [OK]
Common Mistakes:
  • Using arrow (->) operator which is not Java syntax
  • Omitting parentheses when calling methods
  • Using double colon (::) incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes