Professional Documents
Culture Documents
Assignment Week 3
Assignment Week 3
2.65 Name of method is setCredits, name of parameter is creditValue and the type of parameter is
integer
2.69 public Person(String myName, int myAge) { name = myName; age = myAge; }
2.75 Henr557
2.76 This will not compiler, because range of the getLoginName() method is too large for student
instance “djb”, and that why this method wouldn’t run.
2.77
Add conditional statements to the constructor of Student to print an error message if either the length of
the fullNameparameter is less than four characters, or the length of the studentId parameter is less than
three characters. However, the constructor should still use those parameters to set
the name and id fields, even if the error message is printed. Hint: Use if-statements of the following form
(that is, having no else part) to print the error messages.
if(fullName.lenght()<4) {
System.out.prinln(“Error”);
}
If(studentId.lenght()<3){
System.out.prinln(“Error”);
}
2.79
99+3
returned int 102
"cat" + "fish"
returned String "catfish"
"cat" + 9
returned String "cat9"
9 + 3 + "cat"
returned String "12cat"
"cat" + 3 + 9
returned String "cat39"
"catfish".substring(3,4)
returned String "f"
"catfish".substring(3,8)
Exception occurred.
“catfish” String
In this exercise everything was working as expected.