Question

In: Computer Science

1. The "else" clause is required for a decision statement. 2. A String variable can be...

1. The "else" clause is required for a decision statement. 2. A String variable can be assigned to an integer variable. 3. An integer variable can be assigned to a boolean variable. 4. We can calculate the square root of numbers with the class java.util.Math. 5. String is a Java primitive data type. 6. A ‘Double’ object can be assigned to a ‘String’ data variable. 7. Every Java class has to have a static main() method to avoid compilation error. 8. The Random class has a method that can generate binary random numbers. 9. There is no compilation error if we assign a boolean variable to another integer variable. 10. It’s fine to use “new Scanner()” without importing any package. 11. A switch statement must have the “default” clause 12. When you increment the value of an un-initialized integer variable, the variable value will be 1 larger than before 13. We can use String equals() method to determine if a string is larger than another string. 14. JOptionPane.showInputDialog() does not return an integer value. 15. To declare a constant integer, we can use ‘const int’. 16. We can use the Integer class to convert a string to an integer. 17. The "%d" formatter can be used in System.out.printf() to format a string 18. It’s possible to compare a string and an integer. 19. An “if” statement can be nested inside a “switch” statement.

Write true or false for this objective questions in java language

Solutions

Expert Solution

1. False. "If" need not have an "else" statement.

2. False. No, these are two incompatible types and string cannot be assigned to integer.

3. False. Integer cannot be assigned to boolean.

4. False. sqrt is in "java.lang.Math" not "java.util.Math".

5. False. "String" is not a primitive type, only byte, short, int, long, float, double, boolean and char.

6. False. Double cannot be assigned to String.

7. False. Only the class which is executed at the start must have a main method, other classes need not.

8. True. The "nextBoolean" function in Random class can generate binary random numbers.

9. False. Boolean cannot be assigned to integer.

10. False. "Scanner" is in java.util which needs to be imported to use Scanner.

11. False. Default is not necessary in switch.

12. False. Java gives an error if an operation is performed on an unitialized variable.

13. False. "equals()" only checks if two strings are the same. It cannot be used for comparison.

14. True. showInputDialog() returns a String, not an integer.

15. False. "const" is not a Java keyword, "final" must be used instead.

16. True. The "parseInt" method in Integer class can be used to convert string into an integer.

17. False. "%d" is used to format integer values, not string.

18. False. Integer and string cannot be compared.

19. True. Yes, an "if" can be nested inside "switch".

Comment in case of any doubts.


Related Solutions

1. Which if clause, if any, will properly determine if a dollars variable is between .01...
1. Which if clause, if any, will properly determine if a dollars variable is between .01 and 1000.0, inclusive. Assume dollars is declared as a double variable.( C Programming) answer choices if(dollars >=.01 && 1000.0) if(dollars >= .01 and dollars <= 1000.0) if(dollars > .01 & dollars < 1000.0) if( (1000- dollars) < .01) None of the above options will properly test the range 2. Which of the following is false regarding loops? Group of answer choices The break statement...
Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 - .18 Variable 3 - .30...
Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 - .18 Variable 3 - .30 .27 Variable 4 - .74* .60* .34 Note: * = p < .05 A) What is the proportion of variance in variable 1 that is predicted by variable 3? B) What is the proportion of the variance in variable 2 that is not predicted by variable 4? What are the steps I need to take to solve this problem?
C code required /* * isGreater - if x > y then return 1, else return...
C code required /* * isGreater - if x > y then return 1, else return 0 * Example: isGreater(4,5) = 0, isGreater(5,4) = 1 * Legal ops: ! ~ & ^ | + << >> * Max ops: 24 * Rating: 3 */
What is a balance sheet? 2. What is an income statement? 3. What else, besides and...
What is a balance sheet? 2. What is an income statement? 3. What else, besides and income statement and balance sheet might a lender request from a business wishing to borrow money?
The random variable X can take on the values 1, 2 and 3 and the random...
The random variable X can take on the values 1, 2 and 3 and the random variable Y can take on the values 1, 3, and 4. The joint probability distribution of X and Y is given in the following table: Y 1 3 4 X 1 0.1 0.15 0.1 2 0.1 0.1 0.1 3 0.1 0.2 a. What value should go in the blank cell? b. Describe in words and notation the event that has probability 0.2 in the...
Let ?1 and ?2 have the joint pdf f (?1, ?2)= 6?2     0<?2<?1<1 =0 else where...
Let ?1 and ?2 have the joint pdf f (?1, ?2)= 6?2     0<?2<?1<1 =0 else where A. Find conditional mean and conditional variance ?1given?2 . B. Theorem of total mean and total variance?1given?2 .(urgently needed)
1. Any “case” statement can be written as an “if” statement. True False 2.How many iterations...
1. Any “case” statement can be written as an “if” statement. True False 2.How many iterations does the following “loop” statement have? n = 1 loop do n = n + 1 puts “hey" next unless n = 10 break end 0 7 This loop is syntactically incorrect. 9 8 3.The following two conditional expressions are equivalent outcome wise: n = 1 begin puts n end while n < 1 n = 1 while n < 1 puts n end...
1. Explain why the following statement is true: "All else the same, firms with relatively stable...
1. Explain why the following statement is true: "All else the same, firms with relatively stable sales are able to carry relatively high debt/asset ratios." and the explain how a firm might shift its capital structure so as to change its weighted average cost of capital (WACC). What would be the impact on the value of the firm?
Two observations can be made about variable and absorption costing. First, a variable costing income statement...
Two observations can be made about variable and absorption costing. First, a variable costing income statement classifies cost based on behavior, variable or fixed. An absorption costing income statement classifies cost based on nature (use in manufacturing or selling and administration, etc.). Second, in variable costing income statements, fixed manufacturing costs are excluded from inventoriable costs. In absorption costing income statements, fixed manufacturing costs are included in inventoriable costs. Many large companies prepare both kinds of income statements. For what...
Two observations can be made about variable and absorption costing. First, a variable costing income statement...
Two observations can be made about variable and absorption costing. First, a variable costing income statement classifies cost based on behavior. An absorption costing income statement classifies cost based on character or nature (manufacturing, selling, administrative). Second, in variable costing income statements… fixed manufacturing costs are excluded from inventoriable costs. In absorption costing income statements… fixed manufacturing costs are included in inventoriable costs. Many large companies prepare both kinds of income statements. For what purpose?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT