Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions

Question

Define the term Working Capital Gap.

Answered: 1 week ago