3. (a) [3 marks] Write the programmer's perspective of a method header named "doProcess" that is public, does not return

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

3. (a) [3 marks] Write the programmer's perspective of a method header named "doProcess" that is public, does not return

Post by answerhappygod »

3 A 3 Marks Write The Programmer S Perspective Of A Method Header Named Doprocess That Is Public Does Not Return 1
3 A 3 Marks Write The Programmer S Perspective Of A Method Header Named Doprocess That Is Public Does Not Return 1 (188.46 KiB) Viewed 11 times
3. (a) [3 marks] Write the programmer's perspective of a method header named "doProcess" that is public, does not return any value, has one input argument of type String and throws a "checked" IllegalArgumentException. Only the method header is required. (b) [4 marks] Now write the user's perspective code that calls "doProcess" and handles the checked exception. Just the skeleton is required not the actual code for the user's method. (c) [1 mark] Does the method header require any changes if it throws only unchecked exceptions? (YES/NO) (d) [1 mark] Can a method throw more than one type of checked exception? (YES/NO) (e) [1 mark] Can programmers write their own classes of exceptions in Java? (YES/NO) (Please write your essay question on a separate piece of paper) Question ID: 16376 | Point Value: 10 | Rationale: Tests knowledge of Java checked exceptions and exception handling. | Categories: Briefly define the following concepts with respect to the Java language/program design. 4. (a) [2 marks] What does it mean if a method is declared static? (b) [2 marks] What does it mean if a variable is declared final? (c) [2 marks] What is meant by the term aliasing? (d) [2 marks] What is meant by cohesion? (e) [2 marks] What does it mean if an object variable is null? (Please write your essay question on a separate piece of paper) Question ID: 16342 | Point Value: 10 | Rationale: Tests knowledge of Java concepts. I Categories: 5. (a) [5 marks] Write a method with the following definition. The use of Jave library methods such as in Collections is not allowed. /** * Returns an int[] Array of size 2 containing the indices of the min and max values of the * input Array nums. If the input Argument has multiple min or max values, the index of the * first one is returned e.g. (4,2,5,2,8,2,8,4) -> returns [1, 4). Error handling is not required. "/ public int[] minMaxInd(int[] nums) (b) [5 marks] Write a method with the following definition: * Removes odd values from an ArrayList e.g. (<2,3,6,-4,5>) leaves <2,6,-4> "/ public void removeOdds(ArrayList<Integer> nums) (Please write your essay question on a separate piece of paper) Question ID: 16334 | Point Value: 10 | Rationale: Tests knowledge of Java Array and ArrayList, indexing, loops, varying size of ArrayList and conditionals. | Categories:
Write the code for the following methods: 6. (a) [4 marks] Write a method that takes an int "a" and returns true iff "a" is a prime number. Assume "a" will always be greater than zero. The method should perform less than a/2 divisions. (b) [2 marks] Write a method with the following definition: * Tests if the Array nums is sorted e.g. {1,2,5,7) -> true * {2,5,5,7) -> true, But (4,6,5,10} -> false * No error handling required. Assume that Array nums will neither be null * nor empty but it can have only one element */ public boolean is Sorted (int[] nums) (c) [3 marks] Write a method swapAdjacent with the following definition /** *Swaps the adjacent elements of Array nums e.g. (2,5,1,6)-> (5,2,6,1}. * The method must deal with the situation where the input array length is odd * using Java Exceptions. */ public void swapAdjacent(int nums) (d) [1 mark] The method swapAdjacent does not return any value. How will the calling method access the changed array nums? (Please write your essay question on a separate piece of paper) Question ID: 16325 | Point Value: 10 | Rationale: Tests knowledge of Java Arrays, loops, conditional statements, exceptions, shared memory, array referencing and logic efficiency. I Categories:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply