Which someMethod is called by the following program0 public

Which someMethod is called by the following program0 public class Overload {static void someMethod(Object o) {System.out.println(\"someMethod(Object o) is called\");} static void someMethod (Integer i) {System.out.println(\"someMethod(Integer i) is called\");} static void methodCaller(T t) {someMethod (t);} public static void main(String[] args) {methodCaller(new Integer(5));}} Write nested for-each loops to print a 2-D array in the matrix form.

Solution

Answer:

1.

Both someMethod of Integer and Object are called and prints \"someMethod(Object o) is called\" and \"someMethod(Intger i) is called\" respectively.

2.

class Nestedforeachloop
{
public static void main(String[] args)
{
int[][] array_2d = {{1, 2, 3, 4}, {5, 6, 7, 8}};
for(int[] input: array_2d)
{
for(int value: input)
System.out.print(value);
}
}
}

 Which someMethod is called by the following program0 public class Overload {static void someMethod(Object o) {System.out.println(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site