Q1.Which of the Following Method Headings Are Valid? If They Are Invalid

Q1.Which of the Following Method Headings Are Valid? If They Are Invalid

<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>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us