Question: a) (4 marks) Write a method that takes a String s and a charch, and returns the number of occurrences of ch in s. 5.

a) (4 marks) Write a method that takes a String s and a charch, and returns the number of occurrences of ch in s. 5. // returns the number of times ch occurs in s public int count(String s, char ch) For example, count("assess, s") returns 4. b) (6 marks) Use count to write a method that takes a String s and returns a String containing one occurrence of each character in s. // returns a String containing one occurrence of each character in s, in order of their first occurrence in s public String nub(String s) For example, nub("assessme") returns asem", and nub(why") returns why". (Please write your essay question on a separate piece of paper)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
