Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

True/False and explain Evaluate each statement as true or false. Put your answer

ID: 646818 • Letter: T

Question

True/False and explain Evaluate each statement as true or false. Put your answer on the answer line. 1) In a static method, you may use the this parameter either explicitly or implicitly. Answer: _____ 2) A main method can be placed inside a class definition. Answer: _____ 3) You may use methods of the Math class without an import statement. Answer: _____ 4) Wrapper classes provide a class type corresponding to each of the primitive types so that you can have class types that behave somewhat like primitive types. Answer: _____ 5) All versions of Java support automatic boxing. Answer: _____ 6) Wrapper classes are provided for all primitive Java types except Boolean. Answer: _____ 7) A bit may have the value of either a 1 or 0. Answer: _____ 8) Primitive types are reference types. Answer: _____ 9) A class invariant is a statement that is always true for every object of the class. Answer: _____ 10) The String class is a mutable class. Answer: _____ Short Answer 11) Write ONE statement that creates and initializes a static variable named salesTax to 7.59. Answer: ________________________________________ 12) Write ONE statement that creates a constant variable named TAX_RATE. The tax rate is 8.25%. Answer: 13) Write ONE Java statement that computes and displays the value of 2^5. Answer: 14) Write ONE Java statement that computes and displays a random number between 1 and 25. Answer: ________________ 15) Define boxing and unboxing. Answer: ________________ 16) 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: show all your work

Explanation / Answer

Ans 1) False

Explanation:

Static methods belong to a class and are not attached to any specific object of the class. The "this" keyword refers to the current object. Therefore the use of the "this" keyword is not allowed in the context of static method.

Ans 2) True

Explanation: In java, main is a static method from which program execution begins. The main method can be a part of the class definition. If a java program consists of more than one class, the name of the java program is the name of the class that defines the main method.

Ans 3) True

Explanation: Math class is a part of java.lang package that is automatically imported whenever a java code is compiled. Therefore the methods of Math class an be used before using any import statement.

Ans 4) True

Explanation: The main purpose of a wrapper class is to provide constants and methods that can work on primitive data types. For instance, Wrapper classes include certain constants that provide the largest and smallest values for any of the primitive number types.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote