In: Computer Science
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
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!