Java Basics

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

"Can ""_"" be used with numbers (Numeric Literals)? If so how?"

1) Yes 2) The _ character can bse used inbetween digits to allow better reading of code: long creditCard = 1234_5678_9012_3456L; (NOTE: Underscores must be inbetween 2 numbers)

What are the primative types in Java?

1) byte - 8-bit int short - 16-bit int int - 32-bit integer long - 64-bit integer float - 32-bit float double - 64-bit float boolean - 1-bit binary char - 16-bit Unicode

What can float types be expressed as?

1) floats 123.4f; doubles 123.4d; scientific notation 1.234e2;

What is a Class?

1) A CLASS is a blueprint from which individual Objects (instances) are created.

What does a class inherit from a superclass?

1) A class inherits all fields and methods from a superclass (NOTE: It is important to ducment superclasses fields and methods as they are still active when extended)

What is a Class Literal?

1) A class literal refers to the obect (of the type class) that represents itself. Class literals are formed by appending class to a type name: IE: String.class

What is a Controller?

1) A controller does actions based upon the input from the user at a certain URL

What is a Package?

1) A package is a namespace that organize oa set of related classes and interfaces. (package example: com.sethmac.models)

What is a Portlet?

1) A portlet is an application used by a portal website to receive request from clients and return information (View that connects to a Controller)

What is a Servlet?

1) A servelet is a small server residenta program that typically rusn automatically in response to user input (Controlls the actions through the entire process Controller > Work with Data > View) Tomcat is an example

What is a superclass?

1) A superclass is an ansestor of another class Not: In Java classes can have only one direct superclass

"What is an array how is it defined?

1) An array is a container obect that holds a fixed number of values of a specific type 2) int[] anArray; anArray = new int[2]; anArray[0] = 100; anArray[1] = 200; e

What is an Interface?

1) An interface is a group of related methods with empty bodies. interface Bicycle { void speedUp(int increment) } A class that implements Bicycle must provide the body for the speedup method.

What are the implications of Java utilizing UTF-16?

1) CHAR & STRING: You can have characters such as ñ (\u00f1) directly in your code. You can alsu use the unicode escape. FIELD NAMES: Unicode escape sequences can be used in field names.

What are the Java naming conventions for variables?

1) Case Sensitive 2) Should start with a letter (Not a $ or _ ) 3) [a-zA-Z] (Can include _ and $ but conventially does not 4) Use camelCase (No Spaces)

What number systems can represent integers?

1) Decimal - Base 10 (0-9) 1000 Hexadecimal - Base 16 (0-9A-F) 0x0F Binary - Base 2 (0-1) 0b00001 EXAMPLES: int decVal = 26; int hexVal = 0x1a; int binVal = 0b11010; (all equal 26);

Does each class need a main method?

1) No. Each application needs only 1 main method

What is null and how is it often used?

1) Null is a special literal that can bse used as a vlaue for any reference type. Null can be assigned to any variables execpt primative types. 2) Null is often used as a market to indicate an object is unavailable.

"What does it mean when an integer ends with an ""L"" (372L)"

1) That the raw integer value is casted as a long

What happens if you dont give a value to a variable?

1) The compiler supplies a default value usually null or 0. Local variables of Methods cause an error. (It is always a good idea to define a value for variables)

Why is using Interfaces important?

1) Using interfaces allows modulization of code. Different users can implement different methods but all must adhere to the minimal blueprint set by the interface.

What two charastics do all objects have?

"1) Behavoir: What the item does (IE: dog: wag tail bark move eat growl etc) and State: Descriptive peices about an object (Name Color Siz, Shape)"

How should you quote chars and Strings?

"1) Char is single quote. String is double quotes. char capitalC = 'C'; String capitalABC = ""ABC"";"

How does Java handle strings?

"1) To utilize strings in Java you use the java.lang.String class. If you create a variable (field) with double quotes String a = ""a"" it will create a new string."

What are the special escape sequeneces for char and String?

"1) \b - backspace \t - tab \n - new line (line feed) \f - Form feed \r - Carriage Return \"" - Double Quote \' - Single Quote \\ - Backslash"


संबंधित स्टडी सेट्स

communications law midterm (quiz 2)

View Set

CIS - Connect Computer Input Quiz

View Set

French Quiz: La Géographie de la France

View Set

Questions for Adult Health 2 exam #2

View Set

Chap 12 Management of Inf. Syst.

View Set