help 1. When a runtime error occurs, an exception must be thrown so that the pro
ID: 3587881 • Letter: H
Question
help
1. When a runtime error occurs, an exception must be thrown so that the program can catch the exception and handle it or terminate the program. Some exceptions such as ArevindexOutofBoundsExceetig0 are thrown by JVM. Your application can also throw an exception by creating an exception object and throwing it using keyword 2. Select all correct answers from the following descriptions of constructors. a. Every class has at least one constructorIf a class does not declare a constructor, the compiler provides a default constructor b. A constructor can call another constructor in the sme lass by using keyword new c. A class cannot have the same method name as the class name. d. this constructor call must be the first statement in a constructor 3. Select all correct answers from the following descriptions of num types a. An enutype is a special type of class that can declare a set of constants. An SRM class can have instance variables, constructors, and methods. b. You can create an object of an enum type by using keyword new c. An end type must be always declared as an inner class and cannot be declared as a separate file by itself d. If an enwn type has a String type instance variable, you can assign any string to an SRMm type variable. 4. Select the Java features and software engineering practices that apply the principle of least privilege. When the value of a variable must not change after being initialized, you can limit the possibility of inadvertent change of the value by declaring the variable final Once the client classes of a class are implemented using the public instance variables of the class, it is very difficult to make any changes in the internal representation of the class, for example, changing data structures to provide more optimized efficient implementation, changing the variable names or types of the variables. Therefore, instance variables must be declared as private and only public methods that are not likely to change must be provided as public services. protected members of a class can be directly accessed from its subclasses, making the reuse of superclass easy Declaring any variables as instance variables rather than local variables is recommended because it provides a way to easily extend an application in the future. a. b. c. d.Explanation / Answer
1)throw
can rhrow the exception by using keyword throw sytax like
throw new <ExceptionClass><("ExceptionMessage")>
2)a,d
if constructor not defined be user then JVM will insert a default constructor(no param)
if want to call another constructor of same then this call should be first statement in constructor.
3)a
enum can have constructor with private or package scope accessibility.
it can have method as well like getters
all enums are constant and cant be change its value later
4)a,b,c
in java final keyword used make it unchangable
like final int j=9;
then later you cant chage to i=10; because i is final.
for any instance variable they should be private and get] an setters for accessing and modifying those variables
yes protected instance variable is accessibile from its subclass
5)d
all calculations are exact and can be rounding using its defined level
6)extends
for subclassig rhe class extends keywords used
7)super
used super with param if super class have constructor with parameter other like super()
8)c
private things can be only and only will be accessibile from same class
9)d
10)c d b a
more visible access id public
then have protected that can accessibile with package and its sub class
default accessibile within package but in sub class
private only within the class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.