Question

1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of

a.Duck Typing
b.Separation of Concerns
c.Functional Programming
d.Polymorphism
e.Enumerated Values

2-JUnit assertions should be designed so that they

a.Fail (ie, are false) if the code being tested is incorrect
b.Fail (ie, are false) if the code being tested is correct
c.Succeed (ie, are true) if the code being tested is incorrect
d.Always succeed
e.Succeed (ie, are true) if the code being tested is correct

3-Suppose your program converts from Celsius to Fahrenheit, but all the Fahrenheit values are incorrect by 32 degrees. This is a:

a.IOException
b.Syntax error
c.Runtime error
d.Checked Exception
e.Logic error

4-Suppose we are writing an application to list monsters by species. There are two types of monster, Bogeyman and Chupacabra. Each individual monster has a name and a hometown (String), as well as getters and setters. Each *type* of monster has a different method of attack and a different method of choosing victims. What is the best approach?

a.Write unrelated Boogieman and Chupacabra classes
b.Write a Boogieman interface and extend it with a Chupacabra class
c.Write an abstract Monster class and extend it with concrete Boogieman and Chupacabra classes
d.Use a single, concrete Monster class
e.Write a Monster interface and implement it with Boogieman and Chupacabra classes

5-Consider these two statements:

a) It is possible for an instance method to use a static variable

b) It is possible for a static method to use an instance variable without creating an object

Which of the following is correct?

a.Statements a and b are both true
b.Statements a and b are both false
c.Statement a is true and statement b is false
d.Statement a is false and statement b is true

6-Consider this code:

public class SpanishInquisitionAttack {
   public void announce() {
       System.out.println("Nobody Expects the Spanish Inquisition!");
   }
}

Can we create a SpanishInquisitionAttack with code in another class this way:

public SpanishInquisitionAttack a = new SpanishInquisitionAttack();

a.No, because no constructor appears in the code
b.Yes, because SpanishInquisitionAttack does not need any kind of constructor
c.No, because main() is static
d.Yes, because SpanishInquisitionAttack will have an implicit constructor
e.Yes, because main() is static

7-Consider this code:

   j.addEventHandler(MouseEvent.MOUSE_EXITED, e->{

            // [ lines omitted ]
});

This code contains a(n)

a.Static declaration
b.Native method
c.Immutable data structure
d.Lambda expression
e.Recursive call

8-A Java interface can contain

a.Method headers that require implementing classes to provide corresponding methods
b.Instance Variables
c.Code to implement methods
d.Final values (constants)

9-Consider the JavaFX methods addEventHandler() and Application.launch() (the method you call if your JavaFX Application contains a main()) Which of the following is correct?

a.addEventHandler() is a static method and Application.launch() is an instance method
b.addEventHandler() and Application.launch() are both static methods
c.addEventHandler() is an instance method and Application.launch() is a static method
d.addEventHandler() and Application.launch() are both instance methods

10-Suppose Gizmo is a Java interface, PlasmaGizmo is an abstract class that implements Gizmo, and TypeBPlasmaGizmo is a concrete class that extends PlasmaGizmo. Which of the following is/are correct?

a.It is possible to instantiate an ArrayList parameterized by Gizmo
b.It is possible to instantiate an ArrayList parameterized by PlasmaGizmo
c.It is possible to instantiate an ArrayList parameterized by TypeBPlasmaGizmo
d.It is possible to instantiate an object of class Gizmo
e.It is possible to instantiate an obejct of class PlasmaGizmo

11-Suppose Sheep exhibit different behavior according to the number of Sheep that have been instantiated in the application. One Sheep wanders around at random, two Sheep face in opposite directions to watch for predators, and three or more Sheep organize themselves in a circular herd with the larger animals towards the outside and the juveniles on the inside. All of this behavior is coded in the Sheep class. What is the best way to keep track of the number of Sheep in the application?

a.Use a lambda expression
b.Instantiate the Sheep using an implicit constructor
c.Use a static variable
d.Use an instance variable
e.Save each Sheep to a file using text I/O and read the files when the Sheep need to decide what to do

12-Suppose you are writing an application that will model bank accounts. The two types of account, SavingsAccount and CheckingAccount, each have balances, account owners, and account numbers as well as getters and setters for these values. SavingsAccount also has a method, run daily, that calculates interest on the account. Which of the following is the best alternative?

a.Override the calcInterest() method from String
b.Use a single class, include the calcInterest() method, and just don’t use it with checking accounts
c.Both CheckingAccount and SavingsAccount are concrete classes that extend the abstract class Account
d.Both CheckingAccount and SavingsAccount are abstract classes, which are extended by the concrete classes ConcreteCheckingAccount and Concrete SavingsAccount
e.Both CheckingAccount and SavingsAccount implement the interface Account

13-Suppose Bar is a Java interface and BigBar and GinormousBar are concrete classes that implement Bar. Our application contains this line of code:

List<Bar> barList = new ArrayList <Bar>();

Which of the following is/are possible?

a.Instantiate a Bar and add it to the list
b.Instantiate a BigBar and add it to the list
c.Instantiate a GinormousBar and add it to the list
d.Create a class that extends both BigBar and GinormousBar

14-Which of the following statements about binary file I/O is FALSE?

a.It allows an application to read and write entire objects to and from files
b.It uses a plain text file format
c.It requires casting objects when they are read from files
d.It makes parsing code unnecessary
e.The Java code to implement it is platform-independent

15-Consider this code:

EventHandler<InputEvent> mouseHandler = new EventHandler<InputEvent>() {
    boolean wall = false;

    @Override
    public void handle(InputEvent event) {
     wall = toggleWall(j, wall, row, col);
    }
   };

This code contains a(n)

a.Lambda expression
b.Anonymous class
c.Recursive method call
d.Static method

16-Consider this diagram:

Person Address Street City State Postal Code Country Validate Output As Label Name Phone Number Email Address 0..1 lives at Purchase Parking Pass Student Professor Salary Student Number Average Mark s Eligible To Enrol Get Seminars Taken

This is a

a.Class Diagram
b.State Diagram
c.State diagram
d.Interaction Diagram
e.Sequence Diagram

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi Friend,

I have answered first 6 Questions.

Please repost others in separate post.

Q1. b.Separation of Concerns
Q2. a.Fail (ie, are false) if the code being tested is incorrect
Q3. e.Logic error
Q4. c.Write an abstract Monster class and extend it with concrete Boogieman and Chupacabra classes
Q5. c.Statement a is true and statement b is false
Q6. d.Yes, because SpanishInquisitionAttack will have an implicit constructor

Add a comment
Know the answer?
Add Answer to:
1-Suppose you write an application in which one class contains code that keeps track of the...
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
  • Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design...

    Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make Chicken and Cow as subclasses of Dairy. The Sheep and Dairy classes implement the Edible interface. howToEat) and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML...

  • (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal a...

    (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...

  • Define an interface FarmAnimal that contains two methods: getName() and talk(), each returns a string. Declare...

    Define an interface FarmAnimal that contains two methods: getName() and talk(), each returns a string. Declare an abstract class FarmAnimalBase that implements the interface FarmAnimal. In the class FarmAnimalBase, define a private final instance variable name (type: String), a public constructor that initializes the value of the instance variable name, and a public method getName() that returns the value of the instance variable name. Note that we do not implement the method talk() declared in the interface FarmAnimal, that’s the...

  • Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out...

    Y. Daniel Liang’s 8 Class Design Guidelines were posted on the File Manager and handed out in class. Please choose 5 guidelines and discuss them in depth. For each guideline, use 1 page or more for your discussion. You can use the code provided in class to demonstrate your points. The code should not be more than one-third of your writing. 1. Cohesion • [✓] A class should describe a single entity, and all the class operations should logically fit...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is...

    PRG/421 Week One Analyze Assignment – Analyzing a Java™Program Containing Abstract and Derived Classes 1.    What is the output of the program as it is written? (Program begins on p. 2) 2. Why would a programmer choose to define a method in an abstract class (such as the Animal constructor method or the getName()method in the code example) vs. defining a method as abstract (such as the makeSound()method in the example)? /********************************************************************** *           Program:          PRG/421 Week 1 Analyze Assignment *           Purpose:         Analyze the coding for...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans...

    MasterMind in Java Activity MasterMind project Create a new Java Application project named MasterMind allowing Netbeans IDE to create the main class called MasterMind.java MasterMind class Method main() should: Call static method System.out.println() and result in displaying “Welcome to MasterMind!” Call static method JOptionPane.showMessageDialog(arg1, arg2) and result in displaying a message dialog displaying “Let’s Play MasterMind!” Instantiate an instance of class Game() constants Create package Constants class Create class Constants Create constants by declaring them as “public static final”: public...

  • Java Questions A class must implement at least one interface. Question 1 options: True False Question...

    Java Questions A class must implement at least one interface. Question 1 options: True False Question 2 (1 point) Abstract methods can be called. Question 2 options: True False Question 3 (1 point) Constructors Question 3 options: Are inherited but cannot be accessed Are inherited and can be accessed Are accessible but are not inherited Are not inherited and cannot be accessed Question 4 (1 point) We can instantiate an object from an abstract class. Question 4 options: True False...

  • Requirements:  Your Java class names must follow the names specified above. Note that they are...

    Requirements:  Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below.  BankAccount: an abstract class.  SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...

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