Question
1 - Which of the following statements is/are *false*? a.It is possible for an instance method to use a static variable b.It is possible for
1 - Which of the following statements is/are *false*?
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 of its class even if there are no instances c.It is possible for a static method to use a static variable d.It is possible for a static method to use a getter to get an instance value from an object
2 -Suppose the class CoffeeMaker contains a variable of type ACPowerSupply. This is an example of
a. Recursion b.Composition c.Separation of Concerns d.Inheritance e.Polymorphism
3- Suppose Helicopter extends Nuisance. This is an example of
a.Recursion b.Encapsulation c.Inheritance d.Structured Programming e.Composition
4 - Suppose Gizmo is an abstract class, PlasmaGizmo is an abstract class that extends Gizmo, and TypeBPlasmaGizmo is a concrete class that extends PlasmaGizmo. Which of the following is/are correct?
a.It is possible to instantiate an obejct of class PlasmaGizmo b.It is possible to instantiate an object of class Gizmo c.It is possible to instantiate an ArrayList parameterized by TypeBPlasmaGizmo d.It is possible to instantiate an ArrayList parameterized by PlasmaGizmo e.It is possible to instantiate an ArrayList parameterized by Gizmo
5 - 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. Static Typing b. Enumerated Values c. Functional Programming d. Polymorphism e. Separation of Concerns
6 - Suppose PowerSupply is an abstract class and ACPowerSupply and DCPowerSupply are concrete classes that extend PowerSupply. Which of these can be instantiated?
a. PowerSupply b. ACPowerSupply c. DCPowerSupply d. ACDCPowerSupply
7 - Suppose you write a class without specifying that it extends any class. This class will be a subclass of
a. String b. Object c. Class d. Enum e. Event
8- Suppose BurglarAlarm and FireAlarm both implement the interface Alarm. This is an example of
a. Recursion b. Binary IO c. Polymorphism d. Separation of Concerns e. Immutability
9- JUnit assertions are
a. Objects b. Exceptions c. Logical Operators d. Immutable Data Structures e. Static methods
10- 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 correct d.Succeed (ie, are true) if the code being tested is incorrect e.Always fail
11-Suppose your program converts from Celsius to Fahrenheit, but crashes if the user tries to convert the value 0 Celsius. This is a(n):
a.StackOverflowError b.Syntax error c.Runtime error d.Checked Exception e.Logic error
12- Suppose we are writing an application to list monsters by species. There are two types of monster, Bigfoot and Yeti. 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.Use a single, concrete Monster class b.Write a Bigfoot interface and extend it with a Yeti class c.Write unrelated Bigfoot and Yeti classes d.Write an abstract Monster class and extend it with concrete Bigfoot and Yeti classes e.Write a Monster interface and implement it with Bigfoot and Yeti classes
13-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.Both CheckingAccount and SavingsAccount are concrete classes that extend the abstract class Account b.Use a single class, include the calcInterest() method, and just dont use it with checking accounts c.Override the calcInterest() method from String 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
14.Consider this code:
public class PetShop { public void announce() { System.out.println("He's only resting!"); } }
Can we create a PetShop with code in another class this way:
public PetShop p = new PetShop();
a. Yes, because PetShop will have an implicit constructor b.Yes, because PetShop does not need any kind of constructor c.No, because main() is static d.No, because no constructor appears in the code e.Yes, because main() is static
15 - Suppose you write code in Eclipse and, without compiling, see an error message informing you of an unhandled exception. This indicates the presence of a(n)
a.Runtime Error b. Null Pointer c. Recursive Call d. Stack Overflow e.Checked Exception
16 - A Java interface can contain
a. An inner class b. Instance variables c. Method headers that require implementing classes to provide corresponding methods d. Final values (constants) e. Code to implement methods
17-Consider the JavaFX methods addEventHandler() and Application.launch() (the method you call if your JavaFX Application contains a main()) Which of the following is/are *false*?
a. addEventHandler() is an instance method and Application.launch() is a static method b. addEventHandler() and Application.launch() are both static methods c. addEventHandler() is inherited from Object d. Application.launch() is inherited from Application
18- Consider this code:
panicButton.setOnMouseClicked(e->{
// [ lines omitted ] });
This code contains a(n)
a. Static declaration b. Lambda expression c. Immutable data structure d. Instance of JOptionPane e. Recursive call
19- Consider this code:
EventHandler
@Override public void handle(InputEvent event) { foobar = otherObject.getFoobar(); } };
This code contains a(n)
a. Recursive method call b. Lambda expression c. Anonymous class d. Static method
20 -Consider this diagram:
This is a(n)
a. Interaction Diagram b. Entity Relationship Diagram c. State diagram d. Class Diagram e. Sequence Diagram
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started