menu
Qammunity.org
Login
Register
My account
Edit my Profile
Private messages
My favorites
What will be the output of the following code?int p = 3,ch = 2;switch(ch){case 1: System. Out. Println("The square is: " + p*p);break;case 2: System. Out. Println(&quo…
Ask a Question
Questions
Unanswered
Tags
Ask a Question
What will be the output of the following code?int p = 3,ch = 2;switch(ch){case 1: System. Out. Println("The square is: " + p*p);break;case 2: System. Out. Println(&quo…
asked
Nov 5, 2023
227k
views
2
votes
What will be the output of the following code?int p = 3,ch = 2;switch(ch){case 1: System. Out. Println("The square is: " + p*p);break;case 2: System. Out. Println("The cube is: " + p*p*p);break;default: System. Out. Println("No Output Value");}
Computers & Tech
high-school
Netsurfer
asked
by
Netsurfer
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
9
votes
“The cube is: 27”
or p^3
The switch function uses the ch int and identifies a matching case. Because ch is 2
We use case 2
Thus the following line at the top is printed.
Then automatically breaks the function, so we don’t continue.
Kostas Andrianos
answered
Nov 10, 2023
by
Kostas Andrianos
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
Oct 16, 2017
77.7k
views
9. Consider the following code. int x = 2; switch (x) { case 1: x += 3; case 2: x += 5; case 3: x += 7; default: x += 10; } Which syntax correctly prints an array? for (int n = 1; n <= x.length; n++) { System.out.println(x[n]); }
Jonesinator
asked
Oct 16, 2017
by
Jonesinator
8.1k
points
Computers & Tech
high-school
1
answer
2
votes
77.7k
views
asked
Mar 11, 2020
229k
views
What is wrong with the following switch statement? int ans; System.out.print("Type y for yes or n for no"); ans = scan.nextInt(); switch (ans) { case 'y': case 'Y': System.out.println("You said yes");break;
Lancepants
asked
Mar 11, 2020
by
Lancepants
8.5k
points
Computers & Tech
high-school
1
answer
1
vote
229k
views
asked
Jul 16, 2024
40.6k
views
What is the output of running class C? class A { public A() { System.out.println("The default constructor of A is invoked"); } } class B extends A { public B() { System.out.println("The default constructor
Tomaoq
asked
Jul 16, 2024
by
Tomaoq
7.8k
points
Computers & Tech
high-school
1
answer
3
votes
40.6k
views
Ask a Question
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.
9.4m
questions
12.2m
answers
Categories
All categories
Mathematics
(3.7m)
History
(955k)
English
(903k)
Biology
(716k)
Chemistry
(440k)
Physics
(405k)
Social Studies
(564k)
Advanced Placement
(27.5k)
SAT
(19.1k)
Geography
(146k)
Health
(283k)
Arts
(107k)
Business
(468k)
Computers & Tech
(195k)
French
(33.9k)
German
(4.9k)
Spanish
(174k)
Medicine
(125k)
Law
(53.4k)
Engineering
(74.2k)
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.
Seven basic internal components found in a computer tower
Twitter
WhatsApp
Facebook
Reddit
LinkedIn
Email
Link Copied!
Copy
Search Qammunity.org