Java Questions 3

21. Predict the output of the below java program?

a. Parent

b. Runtime error

c. Compile time error

d. Child

 

Ans: b

Error: ‘Cannot override the final method from Parent’ at line 8.

22. Predict the output of the below java program?

a. Parent

b. Child

c. Runtime error

d. Compile time error

 

Ans: a

Explanation: Runtime polymorphism doesn’t occur when methods are static.

23. Predict the output of the below java program?

a. Parent

b. Child

c. Runtime error

d. Compile time error

 

Ans: c

Error: Cannot reduce the visibility of the inherited method from Parent.

24. What is the output?

//

String s1=”selenium web driver tutorials”;
String[] s2=s1.split(” “,3);
for(String s3:s2){
System.out.println(s3);
}

Options:

a. selenium
web
driver tutorials

b. selenium
web driver tutorials

c. selenium web
driver tutorials

d. selenium web driver tutorials

 

Ans: a

 

25.Output.

//

String s1=”selenium,automation,testing,tutorials”;
String[] s2=s1.split(“,”);
for(String s3:s2){
System.out.println(s3);
}

Ans:

selenium
automation
testing
tutorials

26. How to convert char to String in java?

Ans:

//


1. How many ways we can define String in Java?

2. Why Strings are immutable in java?

3. Difference between String buffer and String Builder?

4. Difference between function overloading and overriding?

5. What is runtime polymorphism?

6. Difference between Interface and Abstract class?

7. Is Multiple Inheritance is allowed in Java?

8. Difference between HashMap and Hash Table?

9. Difference between List and Set?

10. Difference between super and this Keyword in Java?

11. Difference between Array and Array List?

12. Difference between While and Do while?

13. Difference between Final and Finally keyword?

14. Can you access the private method from outside the class?

15. How to convert Array List to Array and Array to Array List?

16. What is Garbage collector?

17. Why static is defined to the variables and classes? In what context it is required?

18. Mention the uses of Synchronized block.

19. What is the difference between HashSet and Tree Set? 

20. Difference between public and private Access modifiers


Find maximum number from the two dimensional array.
Sol:

Output: 

Max number is: 72


Tags: selenium interview questions, java interview questions, selenium interview questions for experienced, selenium tutorials for beginners, selenium automation, selenium testing, python automation, python, testng, maven, pom.xml, jenkins, svn, selenium webdriver

Leave a Reply

Your email address will not be published. Required fields are marked *