How do you invoke static methods?

1 answer

Answer

1049069

2026-04-18 12:20

+ Follow

if some method is static, then you can not call that method through the oobject of that class. but the name of the class.

let us see a example:

class Test

{

int a;

int b;

static void show()

{

System.out.println("we are in show");

}

}

class Main

{

public static void main(String args[])

{

Test t=new Test();

t.show();\\thiss is an erroraneous code. because, the method "show()" is static.

Test.show();\\this is correct

}

Arnas Sinha

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.