100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Practice Final Exam 3 Questions With Correct Answers $12.49   Add to cart

Exam (elaborations)

Practice Final Exam 3 Questions With Correct Answers

 0 view  0 purchase
  • Course
  • Institution

Practice Final Exam 3 Questions) With Correct Answers Consider the Counter class below. public class Counter { public int count = 0; public int getCount() { return count; } public void increment() { count++; } } Using the class above and the variables declared belo...

[Show more]

Preview 4 out of 36  pages

  • March 13, 2024
  • 36
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
avatar-seller
Final / Exam 3 - NR293 / NR 293 (Latest 2023 /
2024) : Pharmacology For Nursing Practice -
Chamberlain

1). Consider the counter class below.

public class counter
{
public int count = 0;


public int getcount()
{
return count;
}

public void increment()
{
count++;
}
}
using the class above and the variables declared below, what is the value of
num1.equals(num2)?

counter num1 = new counter();
counter num2 = new counter();

true

false

nothing since equals is not defined for counter

a syntax error

 Ans: false


2). Consider the following code snippet:

public void deposit(double amount)
{



PaperStoc.com Page 1 of 36

, transactioncount++;
super.deposit(amount);
}
which of the following statements is true?



this method will call itself.

this method calls a public method in its subclass.

this method calls a private method in its superclass


this method calls a public method in its superclass.

 Ans: This method calls a public method in its superclass.


3). Consider the counter class below.

public class counter
{
public int count = 0;

public int getcount()
{
return count;
}

public void increment()
{
count++;
}
}
using the class above and the variables declared below, what is the value of
num1.equals(num2)?

counter num1 = new counter();
counter num2 = num1;

true

false

nothing since equals is not defined for counter

a syntax error



PaperStoc.com Page 2 of 36

,  Ans: false


4). What is a class called that represents the most general entity in an inheritance hierarchy?



default class.

superclass.

subclass.


inheritance class.

 Ans: Superclass.


5). Suppose the class value is partially defined below

public class value
{
private int number;
public int getvalue()
{
return number;
}
}
a subclass of value, largervalue, is defined with a getvalue method that returns twice the
value of the parent. which line is the body of largervalue's getvalue method?



return getvalue() * 2;

return super.getvalue() * 2;

return number * 2;

return super.number * 2;

 Ans: return super.getValue() * 2;


6). To ensure that an instance variable can only be accessed by the class that declared it, how
should the variable be declared?




PaperStoc.com Page 3 of 36

, public


private

protected

final

 Ans: private


7). Consider the following code snippet:


employee programmer = new employee(10254, "exempt");
string s = programmer.tostring();
assume that the employee class has not implemented its own tostring() method. what
value will s contain when this code is executed?



s will contain the values of the instance variables in programmer.

s will contain only the class name of the programmer object.

s will contain the class name of the programmer object followed by a hash code.

this code will not compile.

 Ans: s will contain the class name of the programmer object followed by a hash code.


8). Consider the classes shown below:

public class parent
{
public void dosomething() // method 1
{ /* implementation not shown */ }
}

public class child extends parent
{
public void dosomething(int n) // method 2
{ /* implementation not shown */ }

public void dosomething() // method 3
{ /* implementation not shown */ }
}
if the variable kid is defined below, which version of the dosomething method can be called


PaperStoc.com Page 4 of 36

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Academik001. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79064 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.49
  • (0)
  Add to cart