menu
QAmmunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
Ask a Question
Questions
Unanswered
Tags
Categories
Ask a Question
What is output by the following code? public static void stuff(int w) { w -= 2; } public static void main(String a[]) { int n = 2; stuff(n); System.out.print(n); } 1. 0 2. 4 3. 1 4. 3 5. 2
asked
Dec 7, 2018
119k
views
4
votes
What is output by the following code?
public static void stuff(int w) {
w -= 2;
}
public static void main(String a[]) {
int n = 2;
stuff(n);
System.out.print(n);
}
1. 0
2. 4
3. 1
4. 3
5. 2
Computers and Technology
high-school
Johannes Matokic
asked
by
Johannes Matokic
8.1k
points
answer
comment
share this
share
0 Comments
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
6
votes
The output is 2. The stuff() function receives a copy of n, changes it but the result is never used.
OJay
answered
Dec 11, 2018
by
OJay
8.5k
points
ask related question
comment
share this
0 Comments
Please
log in
or
register
to add a comment.
← Prev Question
Next Question →
Related questions
asked
Dec 12, 2024
12.4k
views
Which line(s) of code have a runtime or compile error: package cop3337.exam3; public class COP3337Exam3 public static void main(String[] args) int[] numbers = new int[10]; try try 2 3 for(int i=0; i< 10; i++) numbers [i] = 18 *i; 13 14 if(i%2== 1) throw new Exception("P1"); 15 16 17 if(i%2==0) throw new ArrayIndexOutOfBoundsException("P2"); 18 19 20 //end for catch(ArithmeticException e) System.out.print(e.getMessage() + " L1"); catch(ArrayIndexOutOfBoundsException e) System.out.print(e.getMessage()+" L2 "); catch(Exception e) System.out.println(e.getMessage()+" L3 "); finally throws new Exception("L4"); catch(Exception e) 33 34 35 System.out.println(e.getMessage()+" L5"); 36 37 System.out.print("\\"); //end main 38 39 //end class 12, 32 15 No error in code: 29
Nataliia
asked
Dec 12, 2024
by
Nataliia
7.8k
points
Computers and Technology
high-school
1
answer
5
votes
12.4k
views
asked
Jun 20, 2024
78.7k
views
Public class ArrayCopy { public static void main (String[] argv) { int[][] A = { {1}, {2, 1}, {3, 2, 1}, {4, 3, 2, 1}, {5, 4, 3, 2, 1} }; print (A); int[][] B = copy (A); print (B); } static void print
IFlo
asked
Jun 20, 2024
by
IFlo
7.2k
points
Computers and Technology
college
1
answer
3
votes
78.7k
views
asked
Mar 1, 2024
149k
views
What will the following program print when it is executed? public class Practice11 { public static void main(String args[]) { int i = 0; while (i < 3) { if( i++ == 0 ) System ("Merry"); if( i == 1) System ("Merr"); if( ++i == 2) System ("Mer"); else System ("Oh no!"); } } } (a) Merry Merr Mer (b) MerryMerrMerOh no! (c) MerrMerOh no! (d) MerryMerrMerOh no! MerrMerOh no! MerOh no! (e) Merry.
Grabbag
asked
Mar 1, 2024
by
Grabbag
8.2k
points
Computers and Technology
high-school
1
answer
1
vote
149k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.5m
questions
12.2m
answers
Other Questions
“What does it mean when we “rework” copyrighted material?”
The book shows how to add and subtract binary and decimal numbers. However, other numbering systems are also very popular when dealing with computers. The octal (base 8) numbering system is one of these.
Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to put it in my own words because my English is not that good!
describe an advance in technology that makes life more enjoyable. what discoveries contribute to this technology?
Explain why binary codes are used to represent characters, numbers and symbols :)
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search QAmmunity.org