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

7.4 (keyboard new) What\'s the purpose of keyboard new? Explain what happens whe

ID: 3758546 • Letter: 7

Question

7.4
(keyboard new) What's the purpose of keyboard new? Explain what happens when you use it.

7.5
(default constructors) A class declaresma constructor that takes two parameters. How would you create an instance of the class with no parameters?


7.6
(Instance variable) Explain the purpose of an instance variable.


7.7
(Using classes without importing them) Most classes need to be imported before they can be used in an app. Why is every app allowed to use classes System and String without first importing.


7.8
(Using a class without importing it) Explain how a program could use class scanner without importing it.


7.9
(set and get methods) Explain the disadventage of creating a class that has no set and get methods for an instance varibale.


Only 2-3 sentences for each

Explanation / Answer

7.4
Keyword new:
The new is a keyword which is used to allocated memory of the class object.
When a class object is created with new keyword then memory of the class object
is allocated.
Example :
ClassName objectName=new ClassName();
------------------------------------------------------------------------------------------------------
7.5
The following constructor is the no argument constructor that
takes no arguments.
Example:
//instance of no argument constructor
ClassName objectName=new ClassName();
------------------------------------------------------------------------------------------------------
7.6
Instance variable
The instance variables are belongs to instance of a class.
If class object is created, then an separate instance variable memory is created.
Class accessor and mutator methods works on the state of the instance variables.

Example:

class className
{
private:
instancevariables;
public:
void method1();
void method2();
}

------------------------------------------------------------------------------------------------------
7.7
Java language needs a basic package to start with any machine.
so every java program , by default imports the basic
java.lang.*; package . The basic classes like System, String classes
are by default are accessble to any java program.
------------------------------------------------------------------------------------------------------
7.8
The statement to create Scanner class object is as follows
java.util.Scanner s = new Scanner(System.in);
This is called fully qualified name.

------------------------------------------------------------------------------------------------------

7.9

The instance variable's public methods set and get methods
have fully qualified and can able to access the instance variables
values to set or reset or modify values.

Without set and get methods of the class, the instance variables
are declared as private so it is not possible to other class objects
to access the instance variables status.

So it is a disadvantage of the class that has no set and get method
for an instance variable.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote