Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 5 pages
Class notes

Java coding

Document preview thumbnail
Preview 2 out of 5 pages

Easy understanding for basic java coding

Content preview

modifier TOPIC 3: JAVA LANGUAGE
3.5 METHOD
(METHOD DEFINITION and METHOD CALL for type 3 and Type 4)

Method Definition Method Calls

General Format of Method Definition General Format of Method Calls
classname. methodName (arguments);
public static / static returnType methodName OR
(parameters) { methodName (arguments);
// method body
}
Type 3 : A method definition which return int Type 3 : receive value, pass no
value, receive no parameters arguments
public static int calcProduct( ) {
return 10*10; calcProduct ( ) ;
}
Type 4 : A method definition which return Type 4 : receive value, pass
int value, receive parameters arguments
static int calcAdd(int x, int y) {
return x+y; calcAdd (x, y) ;
}

, Example Coding Using Type 3
class Calculation { Output :
The answer for k is: 17.0
public static void main (String [ ] args){
double result;
result = Calculation. getcalc ( );
System.out.println("The answer for k is:" +result); }
public static double getcalc ( ) {
int x = 5;
double y = 3.0, z = 2.0, k ;
k = (x*y)+z;
return k; } }

Return value type double
Method name getcalc
Formal parameter(passed arguments) ()
Actual parameter(arguments) ()
Parameter list ()
Return value k
Method header public static double getcalc ( ) { }
Method call Calculation .getcalc ( ) ;
Method body {
int x = 5;
double y = 3.0, z = 2.0, k ;
k = (x*y)+z;
return k; }
className Calculation
Method definition public static double getcalc ( ) {
int x = 5;
double y = 3.0, z = 2.0, k ;
k = (x*y)+z;
return k; }

Document information

School year
3
Uploaded on
August 23, 2025
Number of pages
5
Written in
2024/2025
Type
Class notes
Professor(s)
-
Contains
All classes
$3.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
4
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions