Question

Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A....

Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A. (int)(Math.random() * 100) B. (int)(Math.random() * 101) C. (int)(Math.random() * 100) + 1 D. (int)(Math.random() * 100 + 1

Question 23 The not equal comparison operator in Java is ________. A. != = B. <> C. ^= D. !=

Question 24 What is the output of the following fragment? for (int i = 0; i < 15; i++) { if (i % 4 == 1) System.out.println(i + " "); } A. 1 5 9 13 17 B. 1 3 5 7 9 11 13 C. 1 5 9 13 D. 1 4 8 12 Question 25 What is the printout of the following code? double x = 5.5; int y = (int)x; System.out.println("x is " + x + " and y is " + y); A. x is 6 and y is 6 B. x is 6.0 and y is 6.0 C. x is 5.5 and y is 5.0 D. x is 5.5 and y is 5

Question 26 Analyze the following code: if (x < 100) && (x > 10) System.out.println("x is between 10 and 100"); A. The statement has compile errors because (x < 100) && (x > 10) must be enclosed inside parentheses. B. The statement compiles fine. C. The statement has compile errors because (x < 100) && (x > 10) must be enclosed inside parentheses and the println(...) statement must be put inside a block. D. The statement compiles fine, but has a runtime error.

Question 27 Java allows you to declare methods with the same name in a class. This is called ________. A. method redeclaration B. method overriding C. method duplication D. method overloading

Question 28 Arguments to methods always appear within ________. A. parentheses B. quotation marks C. curly braces D. brackets

Question 29 Math.pow(2, 3) returns ________. A. 9 B. 8 C. 9.0 D. 8.0 Question 30 The statement System.out.printf("%10s", 123456) outputs ________. (Note: in rhe answers * represents a space) A. 123456**** B. 12345***** C. 23456***** D. ****123456

0 0
Add a comment Improve this question Transcribed image text
Answer #1
21) B. (int)(Math.random() * 101)
22) Question not given...
23) D. !=
24) A. 1 5 9 13
25) D. x is 5.5 and y is 5
26) A. The statement has compile errors because (x < 100) && (x > 10) must be enclosed inside parentheses.
27) D. method overloading
28) A. parentheses
29) D. 8.0
30) D. ****123456
Add a comment
Know the answer?
Add Answer to:
Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • With a Scanner object created as follows, what method do you use to read an int...

    With a Scanner object created as follows, what method do you use to read an int value? Scanner input = new Scanner(System.in); A. input.int(); B. input.nextInt(); C. input.integer(); D. input.nextInteger(); What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0...

  • QUESTION 3 Assume x = 4 and y = 5, which of the following is true?...

    QUESTION 3 Assume x = 4 and y = 5, which of the following is true? x < 5 || y < 5 x > 5 || y > 5 x < 5 && y < 5 x > 5 && y > 5 QUESTION 14 Which of the following statements are the same? (A) x -= x + 4 (B) x = x + 4 - x (C) x = x - (x + 4) (A) and (B) are...

  • Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c....

    Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c. there’s a syntax error in a Java statement a. the Java compiler can’t be located b. bytecodes can’t be interpreted properly c. there’s a syntax error in a Java statement Flag this Question Question 21 pts An error that lets the application run but produces the wrong results is known as a Group of answer choices d. syntax error c. logic error a. runtime...

  • Need help with a multiple inheritance work Question Compile and run the file. If you find...

    Need help with a multiple inheritance work Question Compile and run the file. If you find any compilation errors,explain their reason as comments in the code. Then fix the errors such that the program compiles and runs. Explain the motivation of your modifications in the code and their effects on the execution inheritance.cpp file #include<iostream> using namespace std; class A { int x; public: void setX(int i) {x = i;} void print() { cout << x; } }; class B:...

  • please help Question 2 (1 point) Saved Choose the option that best describes what happens when...

    please help Question 2 (1 point) Saved Choose the option that best describes what happens when the bolded println() statement is executed: public class Point { public static void main(String[] args) { Point p 1 = new Point(3, 4); System.out.println(p1); } public int x, y; public Point(int xx, int yy) { x = xx; y = yy; } سی Point inherited a toString() method, which is called internally by println(). This is a compile error - println doesn't know how...

  • Question 1 Not yet answered Marked out of 1.00 Flag question Question text Which of the...

    Question 1 Not yet answered Marked out of 1.00 Flag question Question text Which of the following keywords is useful for skipping to the next iteration of a loop? Select one: a. do b. break c. switch d. continue e. while Clear my choice Question 2 Not yet answered Marked out of 1.00 Flag question Question text Consider the following line of Java code. System.out.println("Hello, World!"); "out" is which of the following? Select one: a. a statement b. a class...

  • HINT 1)-Write a method to accept n integer number between 0 and 100 and return the...

    HINT 1)-Write a method to accept n integer number between 0 and 100 and return the average. 2)-Write a method to convert an the letter grade as follow. integer number between 0 and 100 to latter grade A to F and return. 100-90->A 89-80->B 79-70->C 69-60->D 00-59->F 3)-Write a method to compute GPA for following letter grade and return the GPA value. A =>4.0 B ->3.0 C->20 D->1.0 Hint for option 1 1 import java.util.Scanner 2 public class ProjPart2 3...

  • Question 4: If the line does not compile explain why: (10Pts) B objB: // Linel: Linel...

    Question 4: If the line does not compile explain why: (10Pts) B objB: // Linel: Linel compiles: Yes/No class Af (Circle right answer) public: If no, Explain: A(O virtual int output () 0 c objc: Line3 compiles: Yes/No (Cirele right answer) If no, Explain: Line3: private: int i elass B: public A private: D objD: // Line4: Line4 Compiles: Yes/No (Circle right answer) If no, Explain: int j class C ( objc.setx (2) Line5 Compiles: Yes/No (Circle right answer) //...

  • 1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer...

    1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); a.add(new Integer(7)); System.out.println(b.size()); A)1 B)2 C)3 D)4 E)5 2. Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code:     Person p1, p2, p3;     int m1, m2, m3;     p1 = new Person();     m1 = p1.getMoney();     // assignment 1...

  • Question 21 The loop condition can be a complex condition involving several operators. True OR False...

    Question 21 The loop condition can be a complex condition involving several operators. True OR False Question 22 final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87; if(num3-5 >= 2*LIMIT) { System.out.println ("apple"); } else { System.out.println ("orange"); } System.out.println("grape"); What prints? A. Apple B. Orange C. Grape D. apple grape E. orange grape F. Nothing. Question 23 When we use a while loop, we always know in advance how many...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT