- 1
What is the output of this code?
class A { private void print() { System.out.println(''a''); } private void print(String str) { System.out.println(''b''); } private void print(int x) { System.out.println(''c''); } public static void main(String[ ] args) { A object = new A(); object.print(12); } }
4 Answers
0
This is a bad practice. Why donât you use different function names instead?
Unless you need to create a template function for multiple type of objects, you can use generics. Hereâs an article about it:
https://www.geeksforgeeks.org/generics-in-java/
+ 3
Output is - c
Because the third function is running in this class which has integer argument
+ 2
oh yes, you are right...thank you
0
C