Question

Questions 9 and 10 are based on the code fragment below: if ((currentYear % 4 0) && (currentYear 100 !-0)) 11 (current Year 4QUESTION 10 Which of the following statement/s about the refactored code is/are true? (a) Method is LeapYear is an example of

Questions 9 and 10 are based on the code fragment below: if ((currentYear % 4 0) && (currentYear 100 !-0)) 11 (current Year 400 0)) daysInMonth [0]-31; days InMonth [1)-29; daysInMonth [2] -31; daysInMonth [3]-30; days InMonth [4]-31; daysInMonth [5]-30; daysInMonth [6]-31; days InMonth [7]-31; daysInMonth [8] -30; daysInMonth [9] -31; days InMonth [10]-30; daysInMonth [11)-31; ) else daysInMonth [0]-31; days InMonth [1]-28 daysInMonth [2] -31; daysInMonth [3] -30; days InMonth [4] -31 daysInMonth [5] -30; daysInMonth [6] -31; days InMonth [7]-31; daysInMonth [8] -30; daysInMonth [9] -31; days InMonth [10]-30; daysInMonth [11 ]-31; Using various refactorings discussed in lectures, we may rewrite this code as follows: daysInMonth -getDaysInMonth (isLeapYear (currentYear) ) ; private boolean isLeapYear (int year) final int FOUR 4 final int CENTURY 100 final int QUAD CENTURY 400; return (year FOUR 0) (year CENTURY Y0) 11 - (year QUAD CENTURY - 0); private int [] getDays In Month (boolean leapYear) int days - (31,28,31 , 30, 31,30,31,31, 30, 31,30, 31); if (leapYear) days (1) 29 return days QUESTION 9 The refactorings used in the code transformation above were DecomposeConditional, ExtractMethod, ExtractClass DecomposeConditional, ExtractMethod, ExtractConstant DecomposeConditional, ExtractMethod, ExtractConstant, ExtractClass (a) (b) (c) (d) DecomposeConditional, ExtractMethod, ExtractClass, Extractinterface. None of the above. (e)
QUESTION 10 Which of the following statement/s about the refactored code is/are true? (a) Method is LeapYear is an example of the Observer patterm. (b) The methods isLeapYear and getDays InMonth could reasonably be declared public staticto allow wider use The refactored code correctly sets the number of days in February based on whether the current year is a leap year, but leaves other months unchanged from their initial setting (d) Options (a) and (e). Options (b) and (c) (e) QUESTION 11 With respect to Java's collections framework, lists differ from arrays because: arrays are of a fixed size but lists can shrink and grow lists are a primitive type but arrays are a subtype of class Object. any array element can be indexed but lists can be accessed by their endpoints only (a) (b) (c) all the elements of an array must be of the same type, but list elements can all be of different types (d) (e) Options (a) and (d) QUESTION 12 Suppose that you are writing an application which requires standardised, high volume accesses to a back-end SQL database via the JDBC API. You may assume that the tasks involve a mix of simple queries -with variations in the query parameters- and a number of more complex DB operations. The best approach for these high-volume queries is most likely to involve: (a) use of the JDBC:ODBC bridge and carefully constructed groups of Statement objects. use of the JDBC:ODBC bridge, Statement objects and stored procedures a vendor-specific Java DB driver and carefully constructed groups of Statement objects (b) (c) (d) a vendor-specific Java DB driver and wide use of PreparedStatement objects. (e) a vendor-specific Java DB driver and use of PreparedStatements and stored procedures
0 0
Add a comment Improve this question Transcribed image text
Answer #1

9. b) DecomposeConditional, ExtractMethod, ExtraConstant

10. (b) and (c)

11. a) arrays are of fixed size but lists can grow and shrink

12. a) use of the JDBC:ODBC bridge and carefully constructed groups of statement objects.

Add a comment
Know the answer?
Add Answer to:
Questions 9 and 10 are based on the code fragment below: if ((currentYear % 4 0) && (currentYear 100 !-0)) 11 (...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the...

    Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the following data entry error conditions: A number less than 1 or greater than 12 has been entered for the month A negative integer has been entered for the year utilizes a try and catch clause to display an appropriate message when either of these data entry errors exceptions occur. Thank you let me know if you need more info import java.util.*; //Class definition public...

  • Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.

    Create a Java application named Problem14 using the two files Dr. Hanna provided to you—Date.java andProblem14.java—then change his code to add two non-trivial public, non-static methods to the Date class.1. Increment a Date to the next day (for example, 1-31-2011 increments to 2-1-2011; 12-31-2010 increments to 1-1-2011).2. Decrement a Date to the previous day (for example, 2-1-1953 decrements to 1-31-1953; 1-1-1954 decrements to 12-31-1953).. Extra Credit (up to 5 points) Re-write the Date member functions Input() and Output() to usedialog boxes to...

  • help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java -...

    help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java - Eclipse IDE HG2GP Package Explorer X B J "module-info.java X J module-info.java Outline X Assigment 1 @ 1 module doublssalary21 bill import java.util.Scanner; doublosalary2 doublasalary N 4 public class DoubleSalary I DoubleSalary > JRE System Library (JavaSE-14) M 5 public static void main(String[] args) { @ main(Stringni : void 6 Scanner sc = new Scanner(System.in); doublasalary2 System.out.print("Enter number of days: "); 8 ► JRE...

  • Description: This project focuses on creating a Java class, Date.java, along with a client class, DateCleint.java,...

    Description: This project focuses on creating a Java class, Date.java, along with a client class, DateCleint.java, which will contain code that utilizes your Date.java class. You will submit both files (each with appropriate commenting). A very similar project is described in the Programming Projects section at the end of chapter 8, which you may find helpful as reference. Use (your own) Java class file Date.java, and a companion DateClient.java file to perform the following:  Ask user to enter Today’s...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

  • In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand....

    In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task.                                                                                                           Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop                                                                                              int cnt = 1;     do {     cnt += 3;     } while (cnt < 25);     cout << cnt; It runs ________ times    ...

  • Copy all the classes given in classes Calendar, Day, Month, & Year into BlueJ and then...

    Copy all the classes given in classes Calendar, Day, Month, & Year into BlueJ and then generate their documentation. Examine the documentation to see the logic used in creating each class. (Code given below) import java.util.ArrayList; import java.util.Iterator; class Calendar { private Year year; public Calendar() { year = new Year(); } public void printCalendar() { year.printCalendar(); } } class Year { private ArrayList<Month> months; private int number; public Year() { this(2013); } public Year(int number) { this.number = number;...

  • General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You sho...

    General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

  • Chapter 9 Homework 0 Saved 11 Required information (The following information applies to the questions displayed...

    Chapter 9 Homework 0 Saved 11 Required information (The following information applies to the questions displayed below.) Part 2 of 2 Following are transactions of Danica Company. Dec. 13 Accepted a $12,000, 45-day, 8note in granting Miranda Lee a time extension on her past-due account receivable. 31 Prepared an adjusting entry to record the accrued interest on the Lee note. points eBook Jan. 27 Received Lee's payment for principal and interest on the note dated December 13. Mar. 3 Accepted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT