11) Write ONE statement that creates and initializes a static variable named sal
ID: 646886 • Letter: 1
Question
11) Write ONE statement that creates and initializes a static variable named sales Tax to 7.59. 12) Write ONE statement that creates a constant variable named TAX_PATE. The tax rate is 8.25%. 13) Write ONE Java statement that computes and displays the value of 2. Answer: 14) Write ONE Java statement that computes and displays a random number between 1 and Answer: 15) Define boxing and unboxing. Answer: 1 6) Write a Java method that returns true if and only if a character is a digit or a letter. The method should display appropriate feedback to the console. Answer:Explanation / Answer
1) False. Because this refers to an object instance. There is no such object instance inside a call of a static method.
2) True. If the class is public
3) True. Because java.lang.Math is implicitly imported
4) True.
5) False. Autoboxing and unboxing is available from Java 1.5
6) False. boolean also has a wrapper class Boolean
7) True.
8) False. User defined types are reference types
9) True.
10) False. String class is immutable because properties of the String class cannot be changed
11) static float salesTax=7.59;
12) final TAX_RATE = 8.25;
13) Math.pow(2,5);
14) Math.random()*25;
15) Boxing: The automatic conversion of a primitive data type into its equivalent Wrapper type is known as boxing.
Unboxing: The automatic conversion of a wrapper type into its equivalent primitive data type is known as unboxing.
16) public bool isDigitOrLetter(char c){
int ascii= (int) c;
if((ascii>=48 && ascii<=57) || (ascii>=65 && ascii<=90) || (ascii>=97 && ascii<=122)){
System.out.println("Character is a number or letter");
return true;
}else{
System.out.println("Character is NOT a number or letter");
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.