Question One

Giving the following code snippet. What kind of errors you will get and how can you correct it.

A. public class HelloJava
{
public static void main(String args[])
{
int x=10;
int y=2;
System.out.print(x*y=");
System.out.printl(x*y);
}
}
B. public class HelloJava
{
public static void main(String args[])
{
int x=10;
int y=0;
System.out.print(x/y);
}

Question Two

A.Write a program that reads the following string "Hello, This is IT401 assignment 1" and does the following:

1.Use the replace method of the class String and replace IT401 with Business computer language.

2.Print the number of characters in the string after the replacement.

B.Is the replace method of class String an accessor method or a mutator method. Explain your answer.

Question Three

Given the following class create 2 instances of the class and initialize them with the values "Business computer language" and IT401 respectively.

public class GradeBook {
private String courseName;
public GradeBook () {
courseName =""; }
public GradeBook (String name) {
courseName = name; }
public String getCourseName() {
return courseName; }
public void displayMessage() {
System.out.println("welcome, this is" + getCourseName()); }}

Question Four

What are the implicit and explicit parameters for the following methods:

1.Box1.translate(5,10);

2.momSavings.getBalance();

Question Five

Write the following formula in java expression. Show all the required steps. see image.

Coding

In this stage of the case-study, you need to develop a simple Java program that handles University courses. The program needs to have a single class, which contains all the data, constructors and methods relevant to the implementation of the following tasks:

  • Creating a new course and specifying is name, code and the instructor's name.
  • Printing the details of a course (i.e., its name, code and the instructor's name).
  • The course details printed must include the sentence "This is an IT course" if the course starts with IT (i.e., the first two letters of the code are IT). Otherwise, "This is not an IT course" should be printed.
  • Changing the details of a course after it has been created.

Then, test your program by creating and manipulating an object for one course (e.g., IT401) in the main method of a tester class. The test should display:

  • The results of calling all of your methods.
  • The values you expect to get in each method call.

Make sure that your class is designed in accordance with the encapsulation principle, and that all of your methods are properly documented.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.