






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Object-oriented programming (OOP) refers to a type of computer programming (software design) in which programmers define the data type of a data structure, and also the types of operations (functions) that can be applied to the data structure.
Typology: Study Guides, Projects, Research
1 / 10
This page cannot be seen from the preview
Don't miss anything!







- In BlueJ, create a new project called Lab - Create a class in that project called MoreMethods - Write a method in that class called driver that takes no parameters and returns no value - In driver, print the following statement This method calls the others. Stay tuned. - Compile the code and run the method. SOLUTION: Figure 1
- Write a method called max that accepts two double parameters and returns the larger of the two.
Figure 3
- Write a method called sum that accepts one int parameter and returns the sum of the numbers from 1 to the parameter. - In the driver method, print the results of two calls to the sum method: The sum of 1 to 10 is xxx The sum of 1 to 100 is xxx SOLUTION: Figure 4
Figure 5
- Write a method called doubleIt that accepts one String parameter and returns a string that is the parameter concatenated with itself with "XXX" in between. - So calling doubleIt with "Java" will return "JavaXXXJava" - Calling doubleIt with "VT" will return "VTXXXVT" - In the driver method, print the results those two calls.
- Calling halfIt with "Hokies" will return "Hke" - To do this, the method should build the result string one character at a time (use a for loop). - In the driver method, print the results those two calls. SOLUTION: Figure 8 OUTPUT: Figure 9
- Write a method called doIt that accepts one String parameter and one int parameter, and returns a String - If the int parameter is greater than the number of characters in the String parameter, the method should return the result of calling doubleIt on the string. - Otherwise, it should return the result of calling halfIt on the string. - In the driver method, print the results of the following two calls: doIt("Voracious", 7) doIt("Efficacious", 20) SOLUTION: Figure 10 OUTPUT:
Figure 13 -