Ch7 methods questions - CIS 106 Chapter 7 Methods Inclass...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Jamel Jenkins CIS 106 Chapter 7 Methods Inclass Work 02/3/2009 1. Parameters- Can contain the variables, the datatype and arguments of the methods that are passed. a. Arguments- Are the same as parameters of a method b. Method Signature- Is the methodname for the method that is created 2. Methods Headers a. Int sales amount; Int commission; Sales(sales amount,commission); public static int Sales(int a, int c) { b. Int a = 1%2; Oe(a); public static void Oe(int a1) if (a>=1) System.out.println(“The number is odd”); If (a==0) System.out.println(“The number is even”); 3. public class Test { Public static void main(String[]args) { Int num = 89; Int mum = 2; method1(num,mum); } public static void method1(int n, int m) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Jamel Jenkins
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CIS 106 Chapter 7 Methods Inclass Work 02/3/2009 n+=m; xMethod(3.4); System.out.println(n); } public static int xMethod(int n) { if (n > 0) return 1; else if (n ==0) return 0; else if (n < 0) return 1; }} 4. An argument is passed through the methods through the parameters and no the arguments can not have the same name as the parameter being used. 5. What is wrong in the following program? public class Test { public static void method(int x) { } public static int method(int y) { return y; } } Answer: The second method needs to be changed to method1 because you can not overload this program because there is no return statement for y and not x....
View Full Document

Page1 / 2

Ch7 methods questions - CIS 106 Chapter 7 Methods Inclass...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online