Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Refer to the Java classes below: public class BankAccount { private double myBalance; public BankAccount() { myBalance = 0; } public BankAccount(double Balance) {

1. Refer to the Java classes below: public class BankAccount { private double myBalance; public BankAccount() { myBalance = 0; } public BankAccount(double Balance) { myBalance = balance; } public void deposit (double amount) { myBalance += amount; } public double getBalance() { return myBalance; } } public class SavingsAccount extends BankAccount { private double myInterestRate; public SavingsAccount() { /* implementation not shown */ } public SavingsAccount(double balance, double rate) { /* implementation not shown */ } public void addInterest() { /* implementation not shown */ } } Which of the following correctly implements the default constructor of the SavingsAccount class?

I myInterestRate =0; super(); II super(); myInterestRate = 0; III super();

Select one:

a. II only

b. I and II only

c. II and III only

d. III only

e. I, II, and III

2. In the following Haskell function identify the code that implements the base case.

sfac s n = if n == 0 then s else sfac (s*n) (n-1)

Select one:

a. if n == 0

b. if n == 0 then s

c. else sfac (s*n) (n-1)

d. There is no base case in this example

3. True/False: An advantage of the array is that is ensures that all values are always in sorted order.

4. In the following example EBNF grammar, what does the symbol describe?

:= '-'? + ('.' +)? := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Select one:

a. An Integer

b. A real number

c. A character

d. A string

5. Using your knowledge of binding, lifetime, and scope rules, determine what the following code will produce as output ... assume that the code in in the Java language:

public class test { public static void main(String[] args) { int x,y; x=1; y=my_int(x); System.out.println(x); } static int my_int(x) { x = 5; return(x+x); } }

Select one:

a. 5

b. 10

c. 1

d. None of these answers

6. Given that n and count are both of type int, which statement is true about the following Java code segments? I for (count=1; count <= n; count++) System.out.println(count); II count = 1; while (count <= n) { System.out.println(count); count++; }

Select one:

a. I and II are exactly equivalent for all input values of n.

b. I and II are exactly equivalent for all input values n>= 1, but differ when n<= 0.

c. I and II are exactly equivalent only when n = 0.

d. I and II are exactly equivalent only when n is even.

e. I and II are not equivalent for any input values of n.

7. Which of the following choices is the following regular expression most likely to match?

[-+]?[0-9]*\.?[0-9]+

Select one:

a. A floating point number

b. An integer number

c. A telephone number

d. A username string

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

Discuss the importance of workforce planning.

Answered: 1 week ago

Question

Differentiate between a mission statement and a vision statement.

Answered: 1 week ago