Question

In: Computer Science

java True or False. no need to explain 6. Class member variables should be declared as...

java True or False. no need to explain

6. Class member variables should be declared as private because the objectoriented programming principle of encapsulation.

7. The method public char getChar(); will return a character data. Page 2

8. Assume that there is a Class named Stock and the class has a constructor private Stock(String symbol, double price); So a programmer can create a Stock object by doing the following in the main method: Stock stock = new Stock(“Google Inc”, 578.45);

9. A breakpoint is a marker that you can set to specify where execution should pause when you are running your Java application in Eclipse.

10. We use int [] numbers to create a number of integer values in the heap

Solutions

Expert Solution

Ques 6:

The answer is True

Explanation:

Yes, the class member variables should always be declared as private as it is a property of encapsulation that, member variables should not get modified directly without using getters and setters.

Ques 7:

the answer is True

Explanation:

public char getChar() represents a method named getChar which has the return type char and hence it will return the data of character type.

Ques 8:

the answer is True

Explanation:

This is because, the constructor is having two values, that is, symbol and price and as mentioned if we create an object of Stock class using the new keyword, then it will be created with the given values.

Ques 9:

the answer is True

Explanation:

This is true as we can insert breakpoints into our program in Java, so that we can debug the program for any errors or misbehaviour.

Ques 10:

the answer is false

Explanation:

Only int[] numbers is not enough to store some integer numbers on the heap.

new keyword is required to actually allocate some space for the integers inside the heap.

int[] numbers = new int[10];

like this.

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!


Related Solutions

Java Write a Payroll class as demonstrated in the following UML diagram. Member variables of the...
Java Write a Payroll class as demonstrated in the following UML diagram. Member variables of the class are: NUM_EMPLOYEES: a constant integer variable to hold the number of employees. employeeId. An array of integers to hold employee identification numbers. hours. An array of integers to hold the number of hours worked by each employee payRate. An array of doubles to hold each employee’s hourly pay rate wages. An array of seven doubles to hold each employee’s gross wages The class...
You need to make an AngryBear class.(In java) The AngryBear class must have 2 instance variables....
You need to make an AngryBear class.(In java) The AngryBear class must have 2 instance variables. The first instance variable will store the days the bear has been awake. The second instance variable will store the number of teeth for the bear. The AngryBear class will have 1 constructor that takes in values for days awake and number of teeth. The AngryBear class will have one method isAngry(); An AngryBear is angry if it has been awake for more than...
(java) Write a class called CoinFlip. The class should have two instance variables: an int named...
(java) Write a class called CoinFlip. The class should have two instance variables: an int named coin and an object of the class Random called r. Coin will have a value of 0 or 1 (corresponding to heads or tails respectively). The constructor should take a single parameter, an int that indicates whether the coin is currently heads (0) or tails (1). There is no need to error check the input. The constructor should initialize the coin instance variable to...
myLinkedList.java>>>>>>>> public class MyLinkedList implements MiniList<Integer>{ /* Private member variables that you need to declare: **...
myLinkedList.java>>>>>>>> public class MyLinkedList implements MiniList<Integer>{ /* Private member variables that you need to declare: ** The head pointer ** The tail pointer */ public class Node { // declare member variables (data and next) // finish these constructors public Node(int data, Node next) {} public Node(int data) {} // HINT: use this() with next = null } // Initialize the linked list (set head and tail pointers) public MyLinkedList() {} @Override public boolean add(Integer item) { return false; }...
True/False Questions. For each question below, please answer “true” or “false” and explain why. 6. A...
True/False Questions. For each question below, please answer “true” or “false” and explain why. 6. A consumer with convex preferences who is indifferent between the bundles (5,2) and (11,6) will like the bundle (8,4) at least as well as either of the first two bundles. Assume these two goods are imperfect substitutes. 7. The marginal rate of substitution is always the same constant number when the goods are imperfect substitutes and no matter how many of each good is being...
QUESTION 6 TRUE/FALSE. EXPLAIN. All actions in which the marginal costs exceeds the marginal benefit should...
QUESTION 6 TRUE/FALSE. EXPLAIN. All actions in which the marginal costs exceeds the marginal benefit should be undertaken. If a firm is experiencing decreasing marginal returns to labor, the firm's production function is ________ at a(n) ________ rate. AND EXPLAIN increasing; increasing increasing; decreasing decreasing; increasing decreasing; decreasing If a competitive market is producing at the efficient quantity, all of the following are true except which one?AND EXPLAIN Total surplus is maximized. Deadweight loss is equal to zero. The efficient...
Circle Class Write a Circle class that has the following member variables: • radius: a double...
Circle Class Write a Circle class that has the following member variables: • radius: a double • pi: a double initialized with the value 3.14159 The class should have the following member functions: • Default Constructor. A default constructor that sets radius to 0.0. • Constructor. Accepts the radius of the circle as an argument. • setRadius. A mutator function for the radius variable. • getRadius. An accessor function for the radius variable. • getArea. Returns the area of the...
Car Class Write a class named Car that has the following member variables: • year. An...
Car Class Write a class named Car that has the following member variables: • year. An int that holds the car’s model year. • make. A string object that holds the make of the car. • speed. An int that holds the car’s current speed. In addition, the class should have the following member functions. • Constructor. The constructor should accept the car’s year and make as arguments and assign these values to the object’s year and make member variables....
Circle Class Write a Circle class that has the following member variables: • radius: a double...
Circle Class Write a Circle class that has the following member variables: • radius: a double • pi: a double initialized with the value 3.14159 The class should have the following member functions: • Default Constructor. A default constructor that sets radius to 0.0. • Constructor. Accepts the radius of the circle as an argument. • setRadius. A mutator function for the radius variable. • getRadius. An accessor function for the radius variable. • getArea. Returns the area of the...
true or false give reason language in java 1.A static inner class can access the instance...
true or false give reason language in java 1.A static inner class can access the instance variables and methods of its outer non-static class 2.executeQuery from statement may return more than one resultset object 3.Connection is java.sql interface that establishes a session with a specific database 4.Writable is an interface in Hadoop that acts as a wrapper class to almost all the primitive data type 5.Text is the wrapper class of string in Hadoop
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT