AND ANSWERS| LATEST UPDATE 100% SOLVED
How do you build a class constructor? same process as building a method, except you do
not provide a return type. Class constructors should be public.
Example: public Bike(int startCadence, int startSpeed, int startGear) {
//constructor body
}
What are the 3 steps of creating a new object? 1. Declaration: start by declaring the object
type as well as the variable name
2. Instantiation: Use the NEW keyword to instantiate the new object
3. Initialize: Use a call to the objects constructor that will initialize the object
Why would you use the number object over primitive data types? 1. You can use it for an
argument for a method that expects an object
2. To use Constants defined by the class
, 3. Use class methods for converting values to and from other primitive data types
How can you format data for output? You can use the format method in the PrintStream
Class. Use this if you want to format a string containing numbers for output.
EX: System.out.format()
How do you convert Strings to Numbers? Each of the Number subclasses provide a method
called valueOf that will convert a string to an object of that type.
Example: Intiger.valueOf()
How do you convert Numbers to Strings? Multiple methods:
Strings s = String.valueOf(x)
Preferred:
String s2 = Intiger.toString(x)
SQL Select Used to select data from a database