Introduction: Why Java Is Needed for Automation Testing
In today’s hiring process, most companies evaluate candidates using an online test before face-to-face interviews. These online assessments often include Core Java interview questions, logical coding problems, and basic automation concepts.
Java is tested heavily because:
- Automation frameworks are built using Core Java
- Java checks your logical thinking and coding skills
- Most automation tools like Selenium, TestNG, JUnit, Cucumber use Java
- Online tests filter candidates based on real coding ability
- Java is used across manual → automation → SDET roles
That’s why preparing for a core java interview questions online test is mandatory for testers, automation engineers, and fresh graduates entering QA roles.
Core Java Topics for Online Tests (What Interviewers Check)
Online tests usually focus on fundamentals + practical coding, not deep theory.
1. OOP Concepts (High Priority)
- Class & Object
- Inheritance
- Polymorphism
- Encapsulation
- Abstraction
2. Java Collections
- List → ArrayList, LinkedList
- Set → HashSet
- Map → HashMap, LinkedHashMap
3. Exception Handling
- try, catch, finally
- Checked vs Unchecked exceptions
4. Multithreading (Basic Level)
- Thread class
- Runnable interface
5. Java 8 Features
- Streams
- Lambda expressions
- forEach()
Core Java Interview Questions Online Test (With Answers & Code)
Q1. Why is Core Java important for automation testing?
Core Java is used to write automation scripts, handle test data, design frameworks, and integrate tools.
Q2. What is JVM?
JVM (Java Virtual Machine) executes Java bytecode and makes Java platform-independent.
Q3. What is OOP?
OOP (Object-Oriented Programming) organizes code into reusable objects.
Q4. Explain inheritance with example.
class Browser {
void open() {
System.out.println(“Browser opened”);
}
}
class Chrome extends Browser {
void test() {
System.out.println(“Testing in Chrome”);
}
}
public class Demo {
public static void main(String[] args) {
Chrome c = new Chrome();
c.open();
c.test();
}
}
Output
Browser opened
Testing in Chrome
Q5. What is polymorphism?
Same method name behaving differently.
class Login {
void login() {
System.out.println(“Login using password”);
}
void login(String otp) {
System.out.println(“Login using OTP”);
}
}
Q6. What is encapsulation?
Wrapping data using private variables and accessing it through public methods.
Q7. Abstract class vs Interface?
| Abstract Class | Interface |
| Can have method body | Methods abstract by default (Java 7) |
| Constructor allowed | No constructor |
| Partial abstraction | Full abstraction |
Q8. What is ArrayList?
Dynamic array that allows duplicate elements.
Q9. ArrayList vs LinkedList?
- ArrayList → Faster access
- LinkedList → Faster insertion/deletion
Q10. HashMap example.
HashMap<String,String> map = new HashMap<>();
map.put(“browser”,”chrome”);
System.out.println(map.get(“browser”));
Output
chrome
Q11. Checked vs Unchecked exception?
- Checked → IOException
- Unchecked → NullPointerException
Q12. Exception handling example.
try {
int a = 10 / 0;
} catch (ArithmeticException e) {
System.out.println(“Exception handled”);
}
Output
Exception handled
Q13. What is multithreading?
Executing multiple threads at the same time.
Q14. Thread vs Runnable?
Runnable is preferred because Java does not support multiple inheritance.
Q15. Java 8 Stream example.
List<Integer> list = Arrays.asList(10,20,30);
list.stream().filter(x -> x > 15).forEach(System.out::println);
Output
20
30
Java Coding Questions Common in Online Tests
Q16. Reverse a string.
String s = “Java”;
String rev = “”;
for(int i=s.length()-1;i>=0;i–){
rev += s.charAt(i);
}
System.out.println(rev);
Output
avaJ
Q17. Find duplicate elements in array.
int[] arr = {1,2,3,2};
for(int i=0;i<arr.length;i++){
for(int j=i+1;j<arr.length;j++){
if(arr[i]==arr[j]){
System.out.println(arr[i]);
}
}
}
Q18. Count words in a string.
String s = “Core Java Testing”;
System.out.println(s.split(” “).length);
Output
3
Selenium + Core Java Questions (Often in Online Tests)
Q19. What is Selenium?
Selenium is an open-source tool used to automate web applications.
Q20. What is WebDriver?
WebDriver controls browsers directly using browser drivers.
Q21. Selenium code to open browser.
WebDriver driver = new ChromeDriver();
driver.get(“https://example.com”);
Q22. What are locators?
Locators identify web elements.
Types:
- id
- name
- className
- xpath
- cssSelector
Q23. Implicit vs Explicit wait.
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.visibilityOf(element));
Java Selenium Coding Challenges (Online Test Level)
Q24. Handle dropdown.
Select select = new Select(driver.findElement(By.id(“country”)));
select.selectByVisibleText(“India”);
Q25. Handle alert.
Alert alert = driver.switchTo().alert();
alert.accept();
Q26. Take screenshot.
File src = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
Real-Time Automation Scenarios (Asked in Advanced Online Tests)
Scenario 1: Page Object Model (POM)
- Base class → Driver setup
- Page classes → Locators & methods
- Test classes → Assertions
Scenario 2: Login Automation Flow
- Launch browser
- Enter username & password
- Click Login
- Validate dashboard
Scenario 3: API + UI Validation
- Call API
- Capture response
- Validate UI data
Scenario 4: Database Validation
- Fetch DB values
- Compare with UI
JUnit Interview Questions (Online Tests)
Q27. What is JUnit?
JUnit is a unit testing framework for Java.
Q28. Common JUnit annotations?
- @Test
- @Before
- @After
TestNG Interview Questions (Online Tests)
Q29. What is TestNG?
TestNG is an advanced testing framework inspired by JUnit.
Q30. Important TestNG annotations?
- @Test
- @BeforeMethod
- @AfterMethod
- @BeforeSuite
Q31. DataProvider example.
@DataProvider
public Object[][] loginData(){
return new Object[][] {{“user”,”pass”}};
}
Selenium + Java + API Practical Example
Response response = RestAssured.get(“/users”);
System.out.println(response.getStatusCode());
Output
200
Framework Design Questions (Sometimes MCQ-Based)
Q32. What is Hybrid Framework?
Combination of POM + Data-Driven + Keyword-Driven frameworks.
Q33. What is Cucumber?
BDD framework using Gherkin syntax (Given-When-Then).
Q34. CI/CD tools used in automation?
- Jenkins
- GitHub Actions
- Azure DevOps
Common Mistakes in Core Java Online Tests
- Weak OOP understanding
- Not practicing coding problems
- Poor time management
- Forgetting Java syntax
- Ignoring exception handling
1-Page Revision Table / Notes
| Area | Key Focus |
| Core Java | OOP, Collections, Streams |
| Selenium | Locators, Waits |
| TestNG/JUnit | Annotations |
| Framework | POM, Hybrid |
| API | Rest Assured |
| CI/CD | Jenkins |
FAQs – Core Java Interview Questions Online Test
Q1. Are coding questions mandatory in online tests?
Yes, most online tests include Java coding problems.
Q2. Is Selenium asked in Core Java online tests?
Often yes, especially for automation roles.
Q3. What difficulty level are online tests?
Usually beginner to intermediate.
Q4. How to prepare effectively?
Practice Core Java coding daily and revise automation basics.
