Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Which of the following are valid method calls? Select all valid method calls given: Select one or more: a. s.isDigit(); b. Character.toUpperCase(c); c. 'c'.length();
1. Which of the following are valid method calls? Select all valid method calls given:
Select one or more:
a.
s.isDigit();
b.
Character.toUpperCase(c);
c.
'c'.length();
d.
c.length();
e.
c.toLowerCase();
f.
c.isDigit();
g.
s.toUpperCase();
h.
"s".length();
i.
Character.isDigit(c);
2.
Which of the following are valid methods? Select all methods that correctly use return statements and would compile.
Select one or more:
a.
public static int maxA(int x, int y) { if (x > y) { return x; } return y; }
b.
public static int maxC(int x, int y) { if (x > y) { return x; } else { return y; } return y; }
c.
public static String methodA(int place) { if (place == 1) { return "first"; } else if (place == 2) { return "second"; } else if (place == 3) { return "third"; } }
d.
public static int indexOfA(char ch, String s) { for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == ch) { return i; } } return -1; }
e.
public static int maxB(int x, int y) { if (x > y) { return x; } else { return y; } }
f.
public static int indexOfB(char ch, String s) { int ret = -1; for (int i = s.length() - 1; i >= 0; i--) { if (s.charAt(i) == ch) { ret = i; } } return -1; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started