Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with these questions? This for Mobile Application Development QUESTI

ID: 3908356 • Letter: I

Question

I need help with these questions? This for Mobile Application Development

QUESTION 1

Data in a C program is global -- accessible and editable from any point in the program.

True

False

2 points   

QUESTION 2

Rectangle

length and width

getArea and getPerimeter

Unknown

2 points   

QUESTION 3

Which of the following is NOT an example of a best practice?

Using an Application Programming Interface (API)

Using inheritance

Using accessor methods

Using the Model-View-Controller design pattern

2 points   

QUESTION 4

Design patterns are just another name for best practices.

True

False

2 points   

QUESTION 5

Which Java keyword forces all subclasses to create their own version of, or override, the method?

abstract

model

template

frame

2 points   

QUESTION 6

UnpoweredVehicle, PoweredVehicle

UnpoweredVehicle, PoweredVehicle, Bicycle, Skateboard, Motorcycle, Car

Bicycle, Skateboard, Motorcycle, Car

Cannot be determined from the diagram

2 points   

QUESTION 7

Match the following code snippets with the concept they exemplify.

generic class

instantiation

accessor method

constructor

subclass

polymorphism

model

view

controller

delegate

public class MakeShapes {
public static void main(String[] args) {
Rectangle rect = new Rectangle(6.0, 8.0);
Circle circ = new Circle(6.0, 8.0);
System.out.println(“Rectangle: ” + getData(rect));
System.out.println(“Circle: ” + getData(circ));
}
public static String getData(Shape s) {
return s.getData();
}
}

function calculate(){
var r = parseFloat(document.getElementById('radius').value);
// Check for nonnumeric data
if(isNaN(r)){
document.getElementById('data').innerHTML = "Please enter
numbers only";
return;
}
// Check for negative data
if(r<=0){
document.getElementById('data').innerHTML = "Negative numbers
don't make sense";
return;
}
// Data is good
var myCircle = new Circle(r);
document.

Square s1 = new Square();

<html>
<head>
<title>Circles</title>
<script src="circle.js"></script>
<script src="controller.js"></script>
</head>
<body>
<h3>Program Calculates Area and Perimeter of Circles</h3>
<p>Enter the radius: <input type="text" id="radius" value="" />
<input type="button" value="Calculate" /></p>
<p id="data"></p>
</body>
</html>

public Cylinder(double rad, double h) {
myCircle = new Circle(rad);
this.height = Circle.checkData(h);
}

public class Triangle extends Shape {
private double s1, s2, s3;
public setSides(double side1, double side2, double side3) {
if ((side1 + side2 > side3) && (side1 + side3 > side2) && ( side2 + side3 > side1) {
s1 = side1;
s2 = side2;
s3 = side3;
}
else {
s1 = 1;
s2 = 1;
s3 = 1;
}
public String getSides() {
return “Side 1: “ + s1 + “ Side 2: “ + s2 + “ Side 3: “ + s3;
}
public double getArea() {
double s = (s1 + s2 + s3);
return Math.sqrt(s * (s-s1) * (s-s2) * (s-s3));
}
public double getPerimeter() {
return s1 + s2 + s3;
}
public String getData() {
return getSides() + “ Area: “ + getArea() + “ Perimeter: “ + getPerimeter();
}
}

public class Cyclinder {
private Circle circle;
private double height;
.
.
.
.
}

public class Square {
private sideLength;
public double getSideLength() {
return sideLength;
}
public void setSideLength(double s) {
sideLength = s;
}

public double getArea() {
return s * s;
}

public void getPerimeter() {
return s * 4;
}
}

function Circle(r){
this.radius = r;
this.getArea = getA;
this.getPerimeter = getP;
this.getData = getD;
}
function getA(){
return this.radius * this.radius * Math.PI;
}
function getP(){
return 2 * this.radius * Math.PI;
}
function getD(){
return 'Area: ' + this.getArea() + '<br />Perimeter: ' +
this.getPerimeter();
}

public String getName() {
//assumes that the class this method belongs to
// contains a data member named name of type String
return name;
}

2 points   

QUESTION 8

Best practices are the result of finding the most successful set of test runs for an application.

True

False

2 points   

QUESTION 9

Rectangle

length and width

getArea and getPerimeter

Unknown

2 points   

QUESTION 10

Which is not a possible outcome of an app with a memory leak?

The app will run without issue.

The app will close itself automatically when it reaches the memory limit.

The app will crash.

The system will crash.

2 points   

QUESTION 11

What is the output of the following code?
public class Rectangle{
// Instance variables
private double length;
private double width;
// Getters and setters for length and width
public double getLength(){
return length;
}
public void setLength(double length){
this.length = checkData(length);
}
public double getWidth(){
return width;
}
public void setWidth(double width){
this.width = checkData(width);
}
// Constructor
public Rectangle(double length, double width){
this.length = checkData(length);
this.width = checkData(width);
}
// Error-checking method
public double checkData(double val){
// If value is negative, make it positive
if(val < 0)
val = val * -1;
return val;
}
public double getArea(){
return length * width;
}
public double getPerimeter(){
return 2 * (length + width);
}
public String getData(){
return "Length: " + this.length + " Width: " + this.width + " Area: " + this.getArea() + " Perimeter: " + this.getPerimeter();
}
}

public class MakeRectangles{
public static void main(String[] args){
Rectangle rect1 = new Rectangle(-4.0, 2.0);
Rectangle rect2 = new Rectangle(8.0, 6.0);
System.out.println("Rectangle 1: " + rect1.getData());
System.out.println("Rectangle 2: " + rect2.getData());
}
}

Rectangle 1:
Length: 4.0
Width: 2.0
Area: 8.0
Perimeter: 12.0
Rectangle 2:
Length: 8.0
Width: 6.0
Area: 48.0
Perimeter: 28.0

Rectangle 1:
Length: -4.0
Width: 2.0
Area: -8.0
Perimeter: -12.0
Rectangle 2:
Length: 8.0
Width: 6.0
Area: 48.0
Perimeter: 28.0

Rectangle 1:
Length: -4.0
Width: 2.0
Area: -8.0
Perimeter: -4.0
Rectangle 2:
Length: 8.0
Width: 6.0
Area: 48.0
Perimeter: 28.0

Rectangle 1:
Length: -4.0
Width: 2.0
Area: 8.0
Perimeter: 12.0
Rectangle 2:
Length: 8.0
Width: 6.0
Area: 48.0
Perimeter: 28.0

2 points   

QUESTION 12

Vehicle

Vehicle, UnpoweredVehicle, PoweredVehicle

Vehicle, UnpoweredVehicle, PoweredVehicle, Bicycle, Skateboard, Motorcycle, Car

Cannot be determined from the diagram

2 points   

QUESTION 13

In the following code, how many Rectangle objects are instantiated?

Rectangle rect1;
Rectangle rect2;
Rectangle rect3 = null;
Rectangle rect4 = new Rectangle(3.0, 1.5);

0

1

2

3

2 points   

QUESTION 14

Which of the following is an example of instantiation?

public static void main(String[] args)

Rectangle rect1 = new Rectangle();

rect1.length = 4.0;
rect1.width = 2.0;

System.out.println(rect1.length + “x” + rect1.width);

2 points   

QUESTION 15

The C programming language is considered what type of language?

Object-oriented (OO)

Scripting

Event-driven

Procedural

2 points   

QUESTION 16

Variables whose scope is the entire class are called instance variables.

True

False

2 points   

QUESTION 17

Objective-C, C#, and Java are all derivatives of the C programming language.

True

False

2 points   

QUESTION 18

Rectangle

double

getArea

Unknown

2 points   

QUESTION 19

Which of the following is a correct definition for a Rectangle class in Java?

public Rectangle class {
double length;
double width;

public double getArea() {
return length * width;
}

public double getPerimeter() {
return 2 * (length+width);
}
}

public Rectangle class {
double length;
double width;

public getArea():double {
return length * width;
}

public getPerimeter():double {
return 2 * (length+width);
}
}

public class Rectangle {
double length;
double width;

public double getArea() {
return length * width;
}

public double getPerimeter() {
return 2 * (length+width);
}
}

public class Rectangle {
double length;
double width;

public getArea():double {
return length * width;
}

public getPerimeter(): double {
return 2 * (length+width);
}
}

2 points   

QUESTION 20

The following Javascript code is most likely in which tier of the Model-View-Controller design pattern?

function Circle(r){
this.radius = r;
this.getArea = getA;
this.getPerimeter = getP;
this.getData = getD;
}
function getA(){
return this.radius * this.radius * Math.PI;
}
function getP(){
return 2 * this.radius * Math.PI;
}
function getD(){
return 'Area: ' + this.getArea() + '<br />Perimeter: ' + this.getPerimeter();
}

Model

View

Controller

Unable to determine

2 points   

QUESTION 21

The following Javascript code is most likely in which tier of the Model-View-Controller design pattern?

function calculate(){
var r = parseFloat(document.getElementById('radius').value);
// Check for nonnumeric data
if(isNaN(r)){
document.getElementById('data').innerHTML = "Please enter
numbers only";
return;
}
// Check for negative data
if(r<=0){
document.getElementById('data').innerHTML = "Negative numbers don't make sense";
return;
}
// Data is good
var myCircle = new Circle(r);
document.getElementById('data').innerHTML = myCircle.getData();
}

Model

View

Controller

Unable to determine

2 points   

QUESTION 22

What term is used to identify when an object hands off some functionality to another object?

Delegate

Client

Slave

Minion

2 points   

QUESTION 23

Which Java keyword indicates the inheritance relationship?

inherits

imports

uses

extends

2 points   

QUESTION 24

Which of the following is an example of dynamic method invocation?

Running a superclass method from a subclass object

Running an object’s method from another program’s main method.

Running an object’s private method from another method within that same object.

Running System.out.println(“Hello World!”);

2 points   

QUESTION 25

Which of the following is the best example of encapsulation?

A main function doing error-checking before setting a Rectangle’s instance variables’ values.

A Rectangle having two instance variables: width and length.

A Rectangle object displaying its own data onscreen.

A Rectangle object setting its height value.

2 points   

QUESTION 26

MVC stands for Model-View-Controller, a design pattern that separates program tasks into different tiers.

True

False

2 points   

QUESTION 27

To use an inherited method, an object must be cast to the superclass before using that method.

True

False

2 points   

QUESTION 28

Which is the most efficient way to concatenate the two strings, “quick brown fox” and “jumped over the lazy dog” in Java?

String string1 = “quick brown fox”;
string1 = string1 + “ jumped over the lazy dog”;

String string1 = “quick brown fox”;
String string2 = string1 + “ jumped over the lazy dog”;

String string1 = “quick brown fox”;
String string2 =“ jumped over the lazy dog”;
String string3 = string1 + string2;

StringBuffer buffer = new StringBuffer(“quick brown fox”);
buffer.append(“ jumped over the lazy dog”);
String string1 = buffer.toString();

2 points   

QUESTION 29

Like object-oriented programs, procedural programs are data centered.

True

False

2 points   

QUESTION 30

In the following code, which lines make up the constructor(s)?
0 public class Bus {
1 private BankAccount ba;
2 private double fuelLeft;
3 private final double FUEL_MAX = 40.0;
4 private final double FUEL_COST = 3.54;
5 public Bus(BankAccount baRef) {
6 fuelLeft = 0;
7 ba = baRef;
8 }
9 public void fillTank() {
10 double cost = (FUEL_MAX - fuelLeft) * FUEL_COST;
11 if (ba.pay(cost) == true) {
12 fuelLeft = FUEL_MAX;
13 }
14 }
15 public double getFuelLeft() {
16 return fuelLeft;
17 }
18 }

Lines 1-4

Lines 5-8

Lines 1-8

Lines 0-18

2 points   

QUESTION 31

In C#, Java, and Objective-C, how many parent classes can a class have?

Depends on the language

0

1

More than 1

2 points   

QUESTION 32

In C#, Java, and Objective-C, String objects are immutable, meaning that after strings are created, they can’t be changed. Therefore, the following code is illegal:

String str1 = “abc”;
str1 = str1 + “123”;

True

False

2 points   

QUESTION 33

The following HTML code is most likely in which tier of the Model-View-Controller design pattern?

<html>
<head>
<title>Circles</title>
<script src="circle.js"></script>
<script src="controller.js"></script>
</head>
<body>
<h3>Program Calculates Area and Perimeter of Circles</h3>
<p>Enter the radius: <input type="text" id="radius" value="" />
<input type="button" value="Calculate" /></p>
<p id="data"></p>
</body>
</html>

Model

View

Controller

Unable to determine

2 points   

QUESTION 34

C#, Java, and Objective-C have automatic garbage collection enabled by default.

True

False

2 points   

QUESTION 35

Which language(s) use(s) the this keyword as a metaphor to refer to the current object within that object’s context?

C# only

Java only

C# and Java

C#, Java, Objective-C

2 points   

QUESTION 36

In C#, Java, and Objective-C, what is the greatest number of subclasses a class can have?

Depends on the language

0

1

More than 1

2 points   

QUESTION 37

What are the more commonly used names for accessor methods?

Getters and setters

Makers and takers

Pushers and pullers

Givers and takers

2 points   

QUESTION 38

Using the concept of dynamic method invocation, where would the program first look for a method?

The current class

The superclass

The root class

The program must explicitly state which class to check first

2 points   

QUESTION 39

In the following code, which lines make up all of the accessor methods?
0 public class Bus {
1 private BankAccount ba;
2 private double fuelLeft;
3 private final double FUEL_MAX = 40.0;
4 private final double FUEL_COST = 3.54;
5 public Bus(BankAccount baRef) {
6 fuelLeft = 0;
7 ba = baRef;
8 }
9 public void fillTank() {
10 double cost = (FUEL_MAX - fuelLeft) * FUEL_COST;
11 if (ba.pay(cost) == true) {
12 fuelLeft = FUEL_MAX;
13 }
14 }
15 public double getFuelLeft() {
16 return fuelLeft;
17 }
18 }

Lines 9-14

Lines 15-17

Lines 9-17

Lines 5-8

2 points   

QUESTION 40

In the following code, how many Rectangle objects are instantiated?

Rectangle rect1 = new Rectangle();
rect1.length = 4.0;
rect1.width = 2.0;
rect1 = new Rectangle(2.0, 1.0);

0

1

2

3

Rectangle

length and width

getArea and getPerimeter

Unknown

Explanation / Answer

QUESTION 1

False

QUESTION 2


length and width

QUESTION 3

Using an Application Programming Interface (API)

QUESTION 4

True

QUESTION 5

abstract

QUESTION 6

UnpoweredVehicle, PoweredVehicle, Bicycle, Skateboard, Motorcycle, Car

QUESTION 7

A ----- Instantiation

B ------ Controller

C ------ Instantiation

D ------ View

E ------ Delegate

F ------ SubClass

G ------ delegate

H ------ Model

I ------ Model

J ----- accessor method

QUESTION 8

False

QUESTION 9


getArea and getPerimeter

QUESTION 10

The app will close itself automatically when it reaches the memory limit.

QUESTION 11

negative values become positive with check method

Rectangle 1:
Length: 4.0
Width: 2.0
Area: 8.0
Perimeter: 12.0
Rectangle 2:
Length: 8.0
Width: 6.0
Area: 48.0
Perimeter: 28.0

QUESTION 12

Vehicle

QUESTION 13

instantiation is done with new

3

QUESTION 14

Rectangle rect1 = new Rectangle();

QUESTION 15

Procedural

QUESTION 16

True

  

QUESTION 17

True

QUESTION 18


Rectangle

QUESTION 19


public class Rectangle {
double length;
double width;

public double getArea() {
return length * width;
}

public double getPerimeter() {
return 2 * (length+width);
}
}




QUESTION 20


Controller

   

QUESTION 21


Controller

QUESTION 22

Delegate

QUESTION 23

extends

QUESTION 24

Running a superclass method from a subclass object

  

QUESTION 25

Which of the following is the best example of encapsulation?

A Rectangle having two instance variables: width and length.

QUESTION 26

True

QUESTION 27

True

QUESTION 28

String string1 = “quick brown fox”;
string1 = string1 + “ jumped over the lazy dog”;

QUESTION 29

False

QUESTION 30



Lines 5-8

QUESTION 31

1

QUESTION 32

True

2 points   

QUESTION 33


View

  

QUESTION 34

True

QUESTION 35

C# and Java

QUESTION 36

More than 1

2 points   

QUESTION 37

Getters and setters

   

QUESTION 38

The superclass

QUESTION 39

Lines 9-17

QUESTION 40

2

Do ask if any doubt. Please upvote.

length and width