Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA HW 1): public int mystery(int x, int y) { if (x >= y) return x - y; else return x + y; } Based

JAVA HW

1): public int mystery(int x, int y)

{ if (x >= y) return x - y; else return x + y; } Based on the code in the accompanying figure, what would be the output of the following statement? System.out.println(mystery(8, mystery(2, 1));

A)

5

B)

7

C)

11

D)

13

2): public class scopeRule //Line 1 { //Line 2 static double intRate = 0.055; //Line 3 static String name; //Line 4 static int t; //Line 5 public static int main(String[] args) //Line 6 { //Line 7 int first; //Line 8 double u, t; //Line 9 String str; //Line 10 //... //Line 11 } //Line 12 public static int first(int x, int y) //Line 13 { //Line 14 int t; //Line 15 //... //Line 16 } public static double salary; //Line 17 public static void funcOne(int first, double x) //Line 18 { //Line 19 char ch; //Line 20 int y; //Line 21 //block one //Line 22 { //Line 23 int u = 18; //Line 24 //... //Line 25 } //end block one //Line 26 } //Line 27 } //Line 28 Which of the following identifiers seen in the accompanying figure is visible in method first?

A)

intRate (Line 3)

B)

local variables of method funcOne

C)

u (Line 24)

D)

first (Line 8)

3): public static double secret(int first, double second)

{

double temp;

if (second > first)

temp = first * second;

else

temp = first - second;

return temp;

}

Which of the following is a valid call to the method in the accompanying figure?

A) secret(5, 4.8);

B) secret(int 5, double 4.8);

C) secret(int x, double y);

D) public static int secret(5, 4.8);

4): public static double secret(int first, double second)

{

double temp;

if (second > first)

temp = first * second;

else

temp = first - second;

return temp;

}

What is the return type of the method in the accompanying figure?

A) public

B) int

C) void

D) double

5): public class scopeRule //Line 1

{ //Line 2

static double intRate = 0.055; //Line 3

static String name; //Line 4

static int t; //Line 5

public static int main(String[] args) //Line 6

{ //Line 7

int first; //Line 8

double u, t; //Line 9

String str; //Line 10

//... //Line 11

} //Line 12

public static int first(int x, int y) //Line 13

{ //Line 14

int t; //Line 15

//... //Line 16

}

public static double salary; //Line 17

public static void funcOne(int first, double x) //Line 18

{ //Line 19

char ch; //Line 20

int y; //Line 21

//block one //Line 22

{ //Line 23

int u = 18; //Line 24

//... //Line 25

} //end block one //Line 26

} //Line 27

} //Line 28

Which of the following identifiers seen in the accompanying figure is visible in main?

A) t (Line 5)

B) salary (Line 17)

C) local variables of method funcOne

D) All identifiers are visible in main.

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions