<p> Kingdom of Saudi Arabia Ministry of Higher Education Al-Maarefa College for Science and Technology Faculty of Computer Science and Information Systems</p><p>Tutorial 7</p><p>,Q1.Which of the following method headings are valid? If they are invalid .explain why</p><p>(public static one(int a, int b (a (public static int thisone(char x (b (public static char another(int a, b (c public static double yetanother (d</p><p>:Q2.Consider the following methods</p><p>(public static int secret(int x } ;int i, j ;i = 2 * x (if (i > 10 ;j = x / 2 else ;j = x / 3 ;return j - 1 { (public static int another(int a, int b } ;int i, j ;j = 0 (++for (i = a; i <= b; i ;j = j + i ;return j { ?What is the output of each of the following program segments ;x = 10 (a ;((System.out.println(secret(x ;x = 5; y = 8 (b ;((System.out.println(another(x, y ;(x = 10; k = secret(x (c ;((System.out.println(x + " " + k + " "+ another(x, k ;x = 5; y = 8 (d ;((System.out.println(another(y, x</p><p>:Q3. Consider the following method</p><p>(public static int mystery(int x, double y, char ch } ;int u ('if ('A' <= ch && ch <= 'R ;((return(2 * x + (int)(y else ;(return((int)(2 * y) - x { ?What is the output of the following Java statements</p><p>;(('System.out.println(mystery(5, 4.3, 'B ;(('System.out.println(mystery(4, 9.7, 'v ;(('System.out.println(2 * mystery(6, 3.9, 'D</p><p>Q4. Write a value-returning method, isVowel, that returns the value true if a given character is a .vowel, and otherwise returns false. Also write a program to test your method</p><p>Q5.Write a method, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit(12345) is 54321. Also, write a program .to test your method</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages2 Page
-
File Size-