Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 2 . 2 3 PointsGrading comment: Why is converting a value of a smaller type to a value of a larger type ( i

Q2.2
3 PointsGrading comment:
Why is converting a value of a smaller type to a value of a larger type (i.e., a \"widening\" conversion) considered \"safer\" than the converse (a \"narrowing\" conversion)?
Save Answer
Q2.3
3 PointsGrading comment:
If we know that boolean A is false but do not know if boolean B is true or false, then:
We do know A && B is false...
...but we do not know whether B || A is true or false.
Please briefly explain why this is so:
Save Answer
Q2.4
3 PointsGrading comment:
Which of the three types of loops (while, do-while, and for) is best suited for working with arrays?
Grading comment:
Why?
Save Answer
Q3
10 PointsGrading comment:
For each of the following, indicate if it is a valid Java identifier or not. (An identifier is any word you use in a program, not just a variable name.)
If it is valid, explain what it would identify using the normal naming conventions.
If it is not valid, explain why it is not valid.
Q3.1
2 PointsGrading comment:
nine
Valid?
Choice 1 of 2:YesChoice 2 of 2:No
Grading comment:
Explanation:
Save Answer
Q3.2
2 PointsGrading comment:
Product
Valid?
Choice 1 of 2:YesChoice 2 of 2:No
Grading comment:
Explanation:
Save Answer
Q3.3
2 PointsGrading comment:
this~other
Valid?
Choice 1 of 2:YesChoice 2 of 2:No
Grading comment:
Explanation:
Save Answer
Q3.4
2 PointsGrading comment:
MAXIMUM
Valid?
Choice 1 of 2:YesChoice 2 of 2:No
Grading comment:
Explanation:
Save Answer
Q3.5
2 PointsGrading comment:
92ndStreet
Valid?
Choice 1 of 2:YesChoice 2 of 2:No
Grading comment:
Explanation:
Save Answer
Q4
10 PointsGrading comment:
Q5.3
2 PointsGrading comment:
System.out.println((iVar1/iVar2)>(iVar2%iVar1));
Save Answer
Q5.4
2 PointsGrading comment:
System.out.println( s2.length()+ s1+ dVar2);
Save Answer
Q5.5
2 PointsGrading comment:
System.out.println((int)(dVar2/ s1.length()));
Save Answer
Q5.6
2 PointsGrading comment:
System.out.println( s2+\" is \"+ iVar2* dVar2);
Save Answer
Q6
12 PointsGrading comment:
Examine the following code snippets:
import java.util.Random;
// Other code...
Random rGen = new Random ();
boolean b1= rGen.nextBoolean (); // Could be either true OR false
int int1=5, int2=10;
String s =\"amenable\";
Indicate the whether the indicated lines execute or not:
Line #01: if ((int2<= int1) && b1)
Line #02: System.out.println(\"a\");
Line #03: else
Line #04: System.out.println(\"b\");
Line #05: if (b1||(int1* int2>= s.length()))
Line #06: System.out.println(\"c\");
Line #07:
Line #08: switch ((int) Math.pow(int2, int1)/--int1){
Line #09: case 10000:
Line #10: System.out.println(\"d\");
Line #11: break;
Line #12: case 25000:
Line #13: System.out.println(\"e\");
Line #14: break;
Line #15: case 50000:
Line #16: System.out.println(\"f\");
Line #17: break;
Line #18: }
Answer at least 5 of the following 6 correctly, indicating whether or not the specified line will execute:
Q6.1
2 PointsGrading comment:
Line #02:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q6.2
2 PointsGrading comment:
Line #04:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q6.3
2 PointsGrading comment:
Line #06:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q6.4
2 PointsGrading comment:
Line #10:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q6.5
2 PointsGrading comment:
Line #13:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q6.6
2 PointsGrading comment:
Line #16:
Choice 1 of 2:YesChoice 2 of 2:No
Save Answer
Q7
10 PointsGrading comment:
Loops:
Examine the following code:
for (int i =5; i >=1; i--){
System.out.print(\"<<\");
for (int j =5; j >=1; j--)
System.out.print((i * j)%2==0?\"-\" : \"*\");
System.out.println(\">>\");
}
Q7.1
4 PointsGrading comment:
Illustrate what would print:
Save Answer
Q7.2
3 PointsGrading comment:
Which lines of output have no dash characters?
Save Answer
Q7.3
3 PointsGrading comment:
Why is this the case?
Save Answer
Q8
10 PointsGrading comment:
Arrays:
For each part, write the line(s) of code required to achieve the specified tasks...
Q8.1
2 PointsGrading comment:
Declare and initialize a String array (call it \"names\") of size 4:
Save Answer
Q8.2
2 PointsGrading comment:
Declare and initialize another String array (call it \"greetings\"), which will contain the predetermined values \"hey\",\"hello\",\"howdy\", and \"greetings\".
Save Answer
Q8.3
3 PointsGrading comment:
Fill names array with strings for any people's names you like.
Save Answer
Q8.4
3 PointsGrading comment:
Write a loop that will print a greeting from greetings followed by a comma and space, followed by the corresponding name (i.e., matching indices in the arrays) from names (on a separate line for each greeting/name pair).
For example: hello, Tracy
Save Answer

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_2

Step: 3

blur-text-image_3

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

(a) Define the objectives of the experiment.

Answered: 1 week ago

Question

Discuss the objectives of discipline and appeals systems

Answered: 1 week ago