+ 1

What is difference between class and method in java

11th Nov 2016, 6:20 PM
ANAND ALABAL
ANAND ALABAL - avatar
4 Answers
+ 3
bro.. both are totally different things. yes there is relationship between them. class is container for methods. class is blueprint for objects. methods shows the behavior of object. ----------------------------- for ex. String s = "Harish"; s=s.toUpperCase(); here 'String' is Claas. 'toUpperCase' is method.
11th Nov 2016, 7:07 PM
Harish Nandoliya
Harish Nandoliya - avatar
+ 2
a class contains methos for execute the tasks that are required
12th Nov 2016, 1:49 AM
Eduardo
Eduardo - avatar
0
class is user defined data type used as template to create one or more object. method is function defined within class is called method ex class Fact { public static void main(String args []) { int n=4; long result=factorial(n); System.out.println("factorial of given number"+result); } static long factorial(int n); { long facta=1; while(n>0) { facta=facta*n; n--; } return facta; } }
12th Nov 2016, 1:43 AM
ANAND ALABAL
ANAND ALABAL - avatar
0
here class is Fact and method is factorial
12th Nov 2016, 2:07 AM
ANAND ALABAL
ANAND ALABAL - avatar