Java Programming Week 3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

15 Terms

1
New cards

What is the anatomy of defining a method in Java?

void <name>() {

<statements> — ( method’s body )

}

2
New cards

How do you call a method?

<name>()

3
New cards

What are some aspects in terms of statement organization?

  • Methods can group statements

  • Hide local variables and implementation

  • Hidden == not changeable/visible by the outside code


4
New cards

Why is hiding information good?

  • Reduces dependencies in the program between parts of the program

  • Decrease complexity

  • Increase flexibility


5
New cards

What does “double” from double method (int parameter ) mean

It is the return type

6
New cards

What does “int parameter” from double method (int parameter ) mean

  • It is the passed parameter that you can pass upon calling

  • Parameter is hidden from outside code


7
New cards

What is difference between methods and functions?

Functions are methods with a return value

8
New cards

What does void mean

The function returns nothing

9
New cards

Where are other methods declared

They are declared at class level not inside other methods

10
New cards

What is the scope of parameters and variables of a method?

They are not visible from the outside code

11
New cards

What is the general idea of recursion?

Divide the problem into:

  • Base cases where method returns x,1,false etc

  • And Reduction to the same problem but of smaller size


12
New cards

What does mutual recursion mean?

The recursion is not a direct call but rather via other method.

f calls g and g calls f

13
New cards

Which is the situation where you use recursion?

When a recursive definition or recurrence relation is known

14
New cards

Which is faster recursion or iteration

Iteration

15
New cards

What are typical errors in recursion?

  • no or incomplete base cases

  • not always reduction in size

  • too many steps in size reduction part