30. What is the value of x after the following statements? int x x=15 % 4; A. 0
ID: 3917994 • Letter: 3
Question
30. What is the value of x after the following statements? int x x=15 % 4; A. 0 B. 3 C. 3.75 D. 4 E. 15 31. If you need to write a method that will compute the cost of some candy, where each piece costs 25 cents, which would be an appropriate method declaration? A. float CalculateCost (char name) B. float CaleulateCost (int countl) C. float CalculateCost int count D. char CalculateCost(int count) 32. What is wrong with the following switch statement? Scanner scan new Scanner (System. in) int ans system out.println(Type y for yes or n for non") ans scan.nextInt) switch (ans) case Y case TY system.out.print( "You said yes "); break case 'n' case N System.out.print( "You said noln") break default System.out.print( "Invalid answern") //End switch A. There are no break statements on two of the cases. B. ans is an integer data type C. Nothing D. break; is illegal syntax. 33. What are the valid indexes for the following array declaration? intiJ myArray new intl251: A. 0-24 B. 0-25 C. 1-24. D. 1-25 34. In a descending sort, which string would be first? A. "Wi11iam" B. "Mary" C. "1776" D. "Begin" E. "begin"Explanation / Answer
30)
int x;
x=15%4;
percentile gives remainder after dividing by the number
so 4*3=12 so 15-12 gives 3 as remainder and x will have 3
31)
ANSWER:B
float calculateCost(int count)
number of candies will be always an integer so input parameter will be int
and then result will be float
32)
B
The ans is of int type.
But with that program will not give any error. it will print "Invalid answer"
33)
A
we can access from 0 to 24
34)
C
The Answer is "1776"
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.