Published using Google Docs
Methods 2 - Theory Questions
Updated automatically every 5 minutes

Needs updating or removing

Methods Assignment 2

Terms and Theory of Methods

In Computer Science 10 (CS10), students were introduced to structured programming.  Structured programming refers to writing programs in one long, continuous sequence.  The computer then executes the program in a line-by-line order. In CS20, we move into Modular Programming.

Some of the answers can be found in chapter 5 from the book Introduction to Computer Science by Carter or you can find them online.  

Optional: You can view the chapter from here.  Read all the way up to the end of Example 3.  You should read but you do not need to write the code in the examples. .

  1. The idea of breaking code into useable chunks is called Modular Programming.  All languages use modular programming but many do not call them “methods”.  
  1. What did we call a ‘method’ in Processing?
  2. What is a third synonym for ‘method’?  

  1. State 3 of the reasons for (or advantages of) using methods IN YOUR OWN WORDS.

  1. A program can have a limitless number of methods but only one ______ method.

  1. True or False - In our classes, we normally define our methods AFTER the main Method.

  1. True of False - Java methods will work even if they are written BEFORE the main method.  (You may need to look this up.)

  1. The running of the method is achieved by invoking it or _________ it (starts with a ‘c’).

  1. Why do Java methods require brackets at the end?  Eg. MethodName( )  In other words, what will java confuse it with if there are no brackets? 

  1. There are two synonymous words used to describe the data that goes inside the brackets of  a method. Those words are:

  1. Define the RETURN VALUE of a method

  1. What type of return value do each of the following String Methods have?  Here is a link to JavaDocs to help.:

        

String Method

Return Type

.equals()

.toLowerCase()

.contains()

.charAt()

.trim()

.endsWith()

11.  Methods that return boolean values are usually used within what type of structure(s)?

12. Assuming site and web are Strings, the following line of code is valid:

          site.toLowerCase().contains(  web.substring( web.indexOf(“/”) , web.length()  )

What type of value would the above line return?

Procedural Programming

By S. Couprie, 2009