AP® Computer Science A glossary

Non-void method

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

A method that returns a value of its return type. The value must be stored in a variable or used in an expression.

Appears in the course and exam description (CED): 1.9.B.2

getHeight() returns an int, so you write int h = p.getHeight(); or use the call inside an expression.

Plant p = new Plant("Fern", 30);
int h = p.getHeight();
System.out.println(h + 5);

Output:

35
Learn it properly, with a checkpoint 1.9 Method Signatures

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure