Question
True or False 1. A Scanner class can be used to read in user input. 2. Example syntax for creating a Scanner to read user
True or False
1. A Scanner class can be used to read in user input.
2. Example syntax for creating a Scanner to read user input is: Scanner input = new Scanner("System.in");
3. The println() statement can be used to provide a prompt to the user.
4. When using printf(), you can use %d as the format specifier for an int type.
5. An import statement, such as the one to import java.util.Scanner should be the very last line in an application.
6. You should always declare your instance variables as type public.
7. Getters are used to set the value of private instance variables.
8. Your application can use a getter to get the current value of an instance variable of an object that your application has created.
9. You must always have an else part for every if statement.
10. The following code will result in the code repeated while i is less than 5, causing the value of i to be printed out as 5. int i = 0; while (i<5); { i++; } System.out.printf("%d", i);
11. for loops can never result in an infinite loop.
12. Pseudocode is helpful for algorithm development.
13. Example syntax for a 3 argument constructor for a Book class that takes an int value, a double, and a String: public Book (int num1, double num2, String name) { bookId = num1; bookPrice = num2; title = name; }
14. Example call to the Book constructor from an application could be: Book myBook = new Book("5", "3.5", "The Rabbit Ran");
15. A no argument default constructor will not be provided automatically by the Java compiler once you have declared your own constructor for a class.
16. Constructors should always have a return type of void.
17. The eight primitive Java types are: boolean, String, int, char, double, float, long, byte.
18. A UML class diagram can be used to design your class.
19. Relational operators can be used to create the condition for an if statement but never a while loop.
20. In Java, && represents a Conditional AND operator.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started