Can you pass object as an argument to a method?

1 answer

Answer

1179608

2026-07-15 14:10

+ Follow

if you have a function or a method that takes Object as a parameter, you can call that function or method and pass an Object as follows:

Let's say you have a class that extends Object and a function as follows

public class A extends Object {

.....

}

void function ( A arg ){

.....

}

To call this function, you need an instance of the class A

A objectInstance = new A();

function(objectInstance);

The next line shows how to pass an instance of the class A to the function.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.