Question: Question 4 (2 point each, 42 points total) For each of the following write T* for true or for false: String name://this is a
Question 4 (2 point each, 42 points total) For each of the following write T* for true or " for false: String name://this is a declaration name = "ABC"://this is an assignment return balance != 0://this is never a legal return return balance != O://this is a legal return if the return type is boolean a method can call another public method from any class it has access to a method can call another method but only if it is in the same class a method can call another method if it is in the same class unless it is private variables declared in a method do not have scope (don't exist) outside that method local variables having the same name and declared in different methods are different variables Constructors must have the same name as their class Constructors are called used the word 'new Constructors are only called when the object is initialized Constructors have no return value, not even void Default constructors can have parameters If you create a constructor, the default Java created constructor will not be available Constructors can call other methods, even other constructors Static variables are available to the whole class and don't need an instance Static methods can be accessed without an object of the class Instance variables can be accessed without an object of the class One class can have two methods of the same name but the signatures must be different One class can have two methods of the same signature but the returns must be different Question 5 (3 points each, 9 points total) Write the method heading for each of the following: A public method that does not take any arguments but gets the name and returns a string A public method that takes in a char and changes variable 'grade to this new char but returns nothing A helper method that checks to see if the item is free. It is only accessed from other methods in the same class. It takes in an int call stockNumber and an Item called thisitem. It returns true or false. Question 6 (3 points each, 9 points total) Write the java code for each of the following: The heading for a public class named Bank: Create a new Bank object named myAce: Access the deposit method, which takes a double, of the object myAce and send it a value of 10.02: Question 7 64 points each, 8 points totalt) Write the constructor heading for each of the following: The default constructor for the Money class: A constructor for the Money class that takes in a double called balance: Question 4 (2 point each, 42 points total) For each of the following write T* for true or " for false: String name://this is a declaration name = "ABC"://this is an assignment return balance != 0://this is never a legal return return balance != O://this is a legal return if the return type is boolean a method can call another public method from any class it has access to a method can call another method but only if it is in the same class a method can call another method if it is in the same class unless it is private variables declared in a method do not have scope (don't exist) outside that method local variables having the same name and declared in different methods are different variables Constructors must have the same name as their class Constructors are called used the word 'new Constructors are only called when the object is initialized Constructors have no return value, not even void Default constructors can have parameters If you create a constructor, the default Java created constructor will not be available Constructors can call other methods, even other constructors Static variables are available to the whole class and don't need an instance Static methods can be accessed without an object of the class Instance variables can be accessed without an object of the class One class can have two methods of the same name but the signatures must be different One class can have two methods of the same signature but the returns must be different Question 5 (3 points each, 9 points total) Write the method heading for each of the following: A public method that does not take any arguments but gets the name and returns a string A public method that takes in a char and changes variable 'grade to this new char but returns nothing A helper method that checks to see if the item is free. It is only accessed from other methods in the same class. It takes in an int call stockNumber and an Item called thisitem. It returns true or false. Question 6 (3 points each, 9 points total) Write the java code for each of the following: The heading for a public class named Bank: Create a new Bank object named myAce: Access the deposit method, which takes a double, of the object myAce and send it a value of 10.02: Question 7 64 points each, 8 points totalt) Write the constructor heading for each of the following: The default constructor for the Money class: A constructor for the Money class that takes in a double called balance
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
