Bird
0
0

Given the following test class snippet, what will be the output if the login fails?

medium📝 Predict Output Q13 of 15
Selenium Java - Page Object Model
Given the following test class snippet, what will be the output if the login fails?
LoginPage login = new LoginPage(driver);
boolean result = login.login("wrongUser", "wrongPass");
System.out.println(result ? "Login Successful" : "Login Failed");

Assuming login() returns true on success and false on failure.
ALogin Failed
BCompilation error
CLogin Successful
DRuntime exception
Step-by-Step Solution
Solution:
  1. Step 1: Understand login method behavior

    login() returns true if credentials are correct, false otherwise.
  2. Step 2: Analyze given credentials and output

    Credentials are wrong, so login() returns false, printing "Login Failed".
  3. Final Answer:

    Login Failed -> Option A
  4. Quick Check:

    False login returns "Login Failed" [OK]
Quick Trick: Check boolean return to decide output [OK]
Common Mistakes:
MISTAKES
  • Assuming login returns exception on failure
  • Confusing true/false return values
  • Ignoring ternary operator logic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes