Methods | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Methods

When you create methods in your class,does the methods require parameters?

4th Feb 2018, 2:57 AM
Enzo
Enzo - avatar
5 Answers
+ 20
That depends on your wish /*for example ::: if u want to print "helloworld" using method , then there is no need of parameters , now if u want to display enetered input using kethod , then u have to pass parameters to the method*/
4th Feb 2018, 4:29 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 3
It's not compulsory. It depends on the task that method perform.
4th Feb 2018, 3:02 AM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar
+ 1
Methods can be created with or without arguments. Method(){//code}
4th Feb 2018, 3:51 AM
Red
Red - avatar
+ 1
Methods are just like functions in C
4th Feb 2018, 5:19 PM
Sumit Kumar
Sumit Kumar - avatar
0
if your behavior is externally influenced on your objects attributes or some event to be executed yes then the method/behaviour needs parameters.
4th Feb 2018, 1:40 PM
Siva Karthikeyan
Siva Karthikeyan - avatar