Question: JAVA questions when 4. (20 marks) Based on we have learnt in our course with our ourse materials, answer the Suppose we are given a

JAVA

JAVA questions when 4. (20 marks) Based on we have learnt inour course with our ourse materials, answer the Suppose we are given

questions when 4. (20 marks) Based on we have learnt in our course with our ourse materials, answer the Suppose we are given a class ETAClass. This given class has a class method someMethod () which accepts no input argument and returns no value, but potentially produces exception of a "special exception type SomeException back to the caller. the details of what this class and method actually do. Answer the coming questions. BRA O o a) Write a public class WONGvg (named related to your surname) in Java for averaging numbers, so that the following program codes could be run as expected with this new class. (Use your own surname, suppose the student surname is WONG in the example program code below) Body of all constructors and methods can have no more than 2 statements. Execution of the codes below would display on console the average result: 5.5 WONGvg ETA = new WONGavg(); WONGvg bETA = new WONGvg (2.2, 8.8); AETA.setAvg ( LETA ); System.out.println( aETA.getAvg() ); [10 marks] o o b) Write a new class method into the new class in a) part, example named chanSquare (), which fulfils the following: Name this method according to your surname (Use your own surname, suppose the student surname is CHAN in the above example) The method accepts one input argument of String, and return no value. The method first calls the given method someMethod (). The method then attempts to convert the input string to int type integer with wrapper class Integer, and display the square value of this int result on console if successfully done in a similar format: 23 square is 529(* Suppose the input string is "23") as sample output below. This also potentially produces exception of NumberFormatException Sample Console Display Output O COP ih 23 square is 529 The method handles all possible exceptions, which simply displays proper message on console similar to the following format based on the exception type, as sample output below: Exception: Type

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!