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

1. [10 points] True or False. For each of the following write “true” or “false”

ID: 3728651 • Letter: 1

Question

1. [10 points] True or False. For each of the following write “true” or “false” on the right.

1

Variable declaration means the same as variable initialization.

2

String is not a primitive data type.

3

Instantiation refers to implementing a method in a class.

4

In Java, every method has a return type.

5

The scope of a variable refers to the size of a variable.

6

The default constructor does not have any parameters.

7

The method signature contains the name of the method and the type of the parameters.

8

A void method has to return an integer number.

9

Any number can be represented as a String variable.

10

If x is true and y is false, what is the value of (x && !y)

2. [10 points] For each of the following statements, circle the correct answer.

1

According to name conventions, the name of a variable should be

MyVar

my_var

myVar

MY_VAR

2

According to name conventions, the name of a constant should be

MyConst

my_const

myConst

MY_CONST

3

According to name conventions, the name of a method should be

MyMethod

my_method

myMethod

MY_METHOD

4

Consider the code

   String s1=””;

What is the value returned by

    s1.length()

0

empty

“ ”

null

5

Consider the code

     String s2=”Hello”;

What is the value returned by

     s2.substring(2);

Hello

ello

llo

lo

1

Variable declaration means the same as variable initialization.

2

String is not a primitive data type.

3

Instantiation refers to implementing a method in a class.

4

In Java, every method has a return type.

5

The scope of a variable refers to the size of a variable.

6

The default constructor does not have any parameters.

7

The method signature contains the name of the method and the type of the parameters.

8

A void method has to return an integer number.

9

Any number can be represented as a String variable.

10

If x is true and y is false, what is the value of (x && !y)

Explanation / Answer

1)Variable declaration means the same as variable initialization.
Ans)False
2)String is not a primitive data type.
Ans)True
3)Instantiation refers to implementing a method in a class.
Ans)False
4)In Java, every method has a return type.
Ans)False
5)The scope of a variable refers to the size of a variable.
Ans)False
6)The default constructor does not have any parameters.
Ans)True
7)The method signature contains the name of the method and the type of the parameters.
Ans)True
8)A void method has to return an integer number.
Ans)False
9)Any number can be represented as a String variable.
Ans)false
10)If x is true and y is false, what is the value of (x && !y)
Ans)True

__________________

1) myVar

2) MY_CONST

3) myMethod

4) 0

5) llo

____________________Thank You