0

Can we use two different methods in a single class? For exmaple, 1) sayHello();. 2) sayHome(); if yes how to calll them?

7th Nov 2016, 3:43 AM
Shridhar Naik
Shridhar Naik - avatar
3 Respostas
+ 2
yes you can create as many method as you want calling is depend on is your method is static or not. If your method is static you can call your method without creating object of that class. class_name.method; if they are not create object like class_name obj = new class_name(); obj.method; for more comment below
7th Nov 2016, 4:17 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
if you dont have an object, u can just run the method using the name of the method followed by parentheses within its own class. If you have the method defined in a separate class, then you have to use the way shown above.
13th Nov 2016, 10:42 PM
Max Diamond
Max Diamond - avatar
0
Yes that is one of the cool features of JAVA.But sorry I don't know how to call them as I am a 9th standard student who has just started exploring JAVA world
10th Dec 2016, 2:56 PM
Anand Chourasiya
Anand Chourasiya - avatar