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

*** In Java *** Please don\'t answer if you are not sure! 1. A local variable is

ID: 3571991 • Letter: #

Question

*** In Java *** Please don't answer if you are not sure!

1. A local variable is an variable that is declared within a method and that is visible only within that method.

True

False

-------------------------------------------------

2. Arrays can be initialized when they are created.

True

False

-------------------------------------------------

3. Arrays cannot be passed as parameters into methods, but their elements can be passed individually.

True

False

-------------------------------------------------

4. The Java operator new is needed to instantiate an object (i.e. create an instance of a Java class).

True

False

-------------------------------------------------

5. An exception is thrown when an array index goes out of bounds.

True

False

-------------------------------------------------

6. The class ArrayList is contained in the package java.util.

True

False

-------------------------------------------------

7. An array index can be any expression that evaluates to a non-negative integer. The value of the index must always be less than the size of the array.

True

False

-------------------------------------------------

8. In Java, [ ] is an operator, called the array subscripting operator.

True

False

-------------------------------------------------

9. To access an element of a two-dimensional array, you need a pair of indices: one for the row position, and one for the column position.

True

False

-------------------------------------------------

10. If an array index is less than zero, an InvalidIndexException exception is thrown.

True

False

-------------------------------------------------

11. You cannot override the default definition of the method toString because it is provided by Java Object class.

True

False

-------------------------------------------------

12. In a method call statement, when passing an array as an actual parameter, you use only its name.

True

False

-------------------------------------------------

13.To determine whether two reference variables of the Integer type point to the same Integer object, we can use either the method equals of the class Integer or the operator ==.

True

False

-------------------------------------------------

Explanation / Answer

1.True

Local variables are visible only within the declared method, constructor, or block.When a method is entered, an area is pushed onto the call stack. This area contains slots for each local variable and parameter. When the method is called, the parameter slots are initialized to the parameter values

2.True

When an object is created in Java by using new operator the identifier holds the reference not the object exactly

int arr=new int[];

because of Array is predifned class in java.

3.False

Pass all the values from an array into a function as parameters

4.True

Classes provide constructor methods to initialize a new object of that type. In a class declaration, constructors can be distinguished from other methods because they have the same name as the class and have no return type.

Instantiating an Object

The new operator instantiates a new object by allocating memory for it. new requires a single argument: a constructor method for the object to be created. The constructor method is responsible for initializing the new object.

5.Ture

using try and catch blocks handled it.

Exception ArrayIndexOutOfException

6.

True

java.util.ArrayList;

7.True

an array index can be any expression that evaluates to a nonnegative integer

8.True

int arr[size]

int arr=new int[];

9True

int arr[r][c]

int arr=new int[][]

10.True

dispaly not a vaid index error.

11.True

it provide by java.lang package by default.

12.False

we have another option is instance creation

13.True

compare objects then use equals()

method otherwise use comapareTo or ==