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

All of the questions are in JAVA coding Chapter 7 Question 1-4, 47 and 48 What c

ID: 3767257 • Letter: A

Question

All of the questions are in JAVA coding

Chapter 7 Question 1-4, 47 and 48

What can you say about the name of a class?

It must start with an uppercase letter.

The Convention is to start with an uppercase letter.

What can you say about the name of construction?

They must be the same name as the class name?

They can be any name, just like other methods.

What is a constructor’s return type?

void

object

The class name

A constructor does not have a return type

It is legal to have more than one constructor in a given class.

true

false.

In the main method of the class GradeClient, you have coded

Grade g = new Grade( ‘B’);

g.letterGrade = ‘A’;// line 10

When you compile, you get the following message:

GradeClient.java:10: error: letterGrade has private access in Grade

g.leterGrade = ‘A’;//line 10

^

1 error

Explain what the problem is and how to fix it.

In the main method of the class GradeClient, you have coded

Grade g = new Grade( “A” );//line 10

When you compile, you get the following message:

GradeClient.java:10: error: incompatible types: String cannot be converted to char

Grade g = new Grade ( “A” );//line 10

Note: Some messages have been simplified; recompile with –Xdiags:verbose to get full output

1 error

Explain what the problem is and how to fix it.

Explanation / Answer

1. What can you say about the name of a class?

Ans:: Name of class should start with Uppercase letter.First letter should be Capital.If class name contains two words then first letter of second word should be capital.

For example::HelloWorld,Circle,etc.

2.What can you say about the name of construction?

Ans:: Constructor name should be same as class name.

3.What is a constructor’s return type?

Ans:: Constructor don't have any return type.

4.It is legal to have more than one constructor in a given class.

Ans:: True.We can use more than one constructor in a class.

5.Explain what the problem is and how to fix it.In the main method of the class GradeClient, you have coded

Grade g = new Grade( “A” );//line 10

When you compile, you get the following message:

GradeClient.java:10: error: incompatible types: String cannot be converted to char

Grade g = new Grade ( “A” );//line 10

Ans::For character it A should be in single quotes