+ 1

What is the difference between a class and a function

16th Sep 2020, 9:19 PM
David Saah
David Saah - avatar
2 Answers
+ 4
A class is the blueprint to create instances or objects that haves attributes and behaviors/functions in class scopes.Class can have one or more functions/methods.But fucrion is block of statements to be executed when called .
16th Sep 2020, 9:28 PM
HBhZ_C
HBhZ_C - avatar
+ 3
Class contains data and methods in java.. Where as a function or method in java is indipendent block of code that perform some task on calling.. In java, methods resides in class. class A { int i =1; public void print() ( System.out.println("hello" + i ) ; } } Here A is Class, And print is a method, Prints some text with i value. Edit: Pls do search before posting question.. I think you can find this answer in lesson as well as from search bar.
16th Sep 2020, 9:25 PM
Jayakrishna 🇼🇳