100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Unit 5 Edhesive Review Test 2023 with complete solution

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
13-03-2023
Written in
2022/2023

Unit 5 Edhesive Review Test 2023 with complete solution This segment of code is found in every program we have made up to this point - though normally it is part of the starter code. Think back to the code practices, choose the correct key words in the correct order that should be used to fill in the blanks: ______ ______ ______ main (String[] args) { } public, static, void A special value that means "no object" is called: null Consider the following code: String w = "potato"; if (Of('e') == -1) { w = w + "es"; } else { w = w + "s"; } Sln(w); What is output? potatoes A ______ is a separate chunk of code that is given a name. method When you need to use a method, you ______ it. call What symbols help to section off the code that is part of a given method? { } Which of the following is a correct method header? _____ _____ _____ doStuff() public static void Consider the following code: public static void doStuff(){int x = 82;if (x % 10 >= 5){Sln("first");}else if (x % 5 >= 2){Sln("second");}else if (x % 20 >= 10){Sln("third");}else if (x % 6 == 2){Sln("fourth");}} What is displayed by the call doStuff()? second A(n) ______ is the local variable in a method that holds the data sent in. formal parameter A(n) ______ is the data sent to a method. actual parameter Which of the following are NOT a legal call to the method: public static void powerOfTwo(double x){Sln(M(2, x));} All of the items listed are legal method calls.

Show more Read less
Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
March 13, 2023
Number of pages
5
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Unit 5 Edhesive Review Test 2023 with complete solution
This segment of code is found in every program we have made up to this point - though
normally it is part of the starter code. Think back to the code practices, choose the
correct key words in the correct order that should be used to fill in the blanks:
______ ______ ______ main (String[] args)
{
}
public, static, void
A special value that means "no object" is called:
null
Consider the following code:
String w = "potato";
if (w.indexOf('e') == -1)
{
w = w + "es";
}
else
{
w = w + "s";
}
System.out.println(w);
What is output?
potatoes
A ______ is a separate chunk of code that is given a name.
method
When you need to use a method, you ______ it.
call
What symbols help to section off the code that is part of a given method?
{}
Which of the following is a correct method header?
_____ _____ _____ doStuff()
public static void
Consider the following code:
public static void doStuff(){int x = 82;if (x % 10 >= 5){System.out.println("first");}else if (x
% 5 >= 2){System.out.println("second");}else if (x % 20 >= 10)
{System.out.println("third");}else if (x % 6 == 2){System.out.println("fourth");}}
What is displayed by the call doStuff()?
second
A(n) ______ is the local variable in a method that holds the data sent in.
formal parameter
A(n) ______ is the data sent to a method.
actual parameter
Which of the following are NOT a legal call to the method:
public static void powerOfTwo(double x){System.out.println(Math.pow(2, x));}
All of the items listed are legal method calls.

, Which of the following uses a parameter correctly?
public static void printBox(int s){//Code}
Consider the following method header:
public static void doThings(int a, double b) {//Code}
Which of the following is a correct call to this method?
doThings(7, 2.5);
Consider the following java program.
class Example {public static void myMethod() {System.out.print("hello ");}public static
void main(String[] args) {myMethod();myMethod();}}
What is printed when this program runs?
hello hello
What is wrong with the following code which uses the circle class from the
edhesive.shapes.Circle class?
Circle c = new Circle();double r = c.setRadius(6.5);
The setRadius method is void, so it doesn't have a return to be stored in a value.
Consider the following code:
class Example {public static void main(String[] args) {doStuff();doStuff();public static
void doStuff() {System.out.println("You called?");}}}
Why does this cause an error when compiled?
The method doStuff can't be defined inside of the main method.
What key word shows that a method will not return a value?
void
Consider the method defined below:
public static void answerPhone() {System.out.println("Ahoy-hoy!");}
How would you call this method from main?
answerPhone();
Looking at the following method:
public static void repeatPrint(String s, int n) {for (int i = 0; i < n; i++) {System.out.print(s +
" ");}}
Which of the parameters are class-type, and which are primitive?
s is class-type, n is primitive
Again, looking at the same method as above:
public static void repeatPrint(String s, int n) {for (int i = 0; i < n; i++) {System.out.print(s +
" ");}}
What is printed when the following call is made from main?
repeatPrint("done", 3);
done done done
When you pass an object to a method, the method receives ______.
a copy of the reference to the object
Consider the following code, which appears in the main method of a class
RegularPolygon myShape = new RegularPolygon(5,
3.5);doStuff(myShape);System.out.println(myShape);
Where doStuff is defined in the same class as:
public static void doStuff(RegularPolygon r) {r.addSides(3);r.setSideLength(2.0);}
What will be printed by the code in main?
regular octagon with side length 2.0

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
magdamwikash23 Western Governers University
Follow You need to be logged in order to follow users or courses
Sold
112
Member since
2 year
Number of followers
94
Documents
5329
Last sold
1 week ago
Magda

NURSING STUDY GUIDES/EXAMS AND NOTES ALL VERIFIED BY EXPERTS All my uploaded documents, exams and essays are verified by relevant experts.I can assure an A or at least 90% if you use any of my documents.

3,9

14 reviews

5
7
4
2
3
2
2
2
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions