Java 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Identifier may not have:

(1) first character may not be a digit,$,or special character (2) no spaces

Identifier may have:

(1) letters a-z || A-Z (2) digits 0-9 (3) underscores (_) (4) dollar sign ($) (5) Case Sensitive

Examples of double data types:

29.75, 1.76, and 31.51 are double data types.

What does this number look like with scientific notation? 47,281.97 ==

4.728197 x 104. (However Java uses E notation)

How many bits are in a Byte?

8

A value that is written into the code of a program.

A literal

The JVM is a program that emulates what?

A micro-processor

Characteristic of a final identifier

All caps, constant, never changes

What Java often referred to as?

An interpreted language

How are escape sequences treated by the compiler?

As 1 character instead of multiple

Java uses what notation to represent values in scientific notation.

E notation (4.728197X104 == 4.728197E4.)

% means

Modulus - binary - Ex: remainder = value % 5;

* means

Multiplication- binary Ex: tax = cost * rate;

Can Byte code instructions be directly executed directly by the CPU?

No

What numbers can integer data types not hold?

Numbers that have a decimal point in them (0.2)

Describe the Java Program Development Process.

Picture Here!

Data types built into the Java Language and are not derived from classes

Primitive

What is a micro-processor?

Processor a multipurpose, clock driven, register based, digital-integrated circuit which accepts binary data as input, processes it according to instructions stored in its memory, and provides results as output.

Who determines the number and type of variables a program will need.

Programmers

Give an example of a variable bring assigned a String literal:

String value = "Hello"; (String Objects unlike other objects can be created this way)

Give an example of variable being created using the "new" keyword

String value = new String("Hello"); (All objects must used this to be created)

What will be discovered in the program during compilation?

Syntax Errors (When will they be found?)

Mistakes that the programmer has made that violates the rules of the programming language.

Syntax Errors(Definition)

What is used to edit and save a Java source code file?

Text editor

If a .java file has a public class, the class must have what?

The same name as the file.

(T/F) Comments are ignored by the compiler.(Why)

True

(T/F) For every left brace, or opening brace, there must be a corresponding right brace, or closing brace.(Why)

True

(T/F) Floating-point literals can be represented in scientific notation.

True 47,281.97 == 4.728197 x 104.

Who writes java programming statements?

Who is the Java Programmer?

How are statements terminated?

With semicolons

Is Java a case-sensitive language?

Yes

Java Reserved Keywords - a

abstract, assert,

+ (means)

addition - binary - Ex: total = cost + tax:

\\

backslash- causes a backslash to be printed

\b

backspace - move cursor left by one position

Java Reserved Keywords - f

false, for, final, finally, float

Run using java or javac

java file name interpreter

Compile using java or javac

javac - filename.java

Special meaning in a programming language are called

keywords

Java Reserved Keywords - r

return

Java Reserved Keywords - s

short, static, strictfp, super, switch, synchronized

\'

single quote - causes a single quotation mark to be printed

- (means)

subtraction -binary - Ex: cost = total - tax;

\t

tab

Name a method of the String class

the length method (stringSize = value.length();

Java Reserved Keywords - t

this, throw, transient, true, try

A named storage location in the computer's memory

variable

Java Reserved Keywords - v

void, volatile

Java Reserved Keywords - w

while

Name Java's 5 arithmetic operators:

+, -, *, /, %

Byte code files end with what?

.class file extension.

Is this correct? grossPay = 1257.00;

// Correct.

Is this correct? grossPay = $1,257.00;

// ERROR! (Literals not allowed to have currency symbols or commas)

4 % 2 =

0

3 % 2=

1

How does the JVM execute instructions?

As they are read.

Name all 8 Jave Primitive data types with values

Boolean(1 bits), byte(8 bits), char(16 bits), short(16 bits), int(32 bits), float(32 bits), long(64 bits), double(64 bits)

Java Reserved Keywords - b

Boolean, break, byte

The machine language of the Java Virtual Machine (JVM) and cannot be directly executed directly by the CPU.

Byte code instructions (Definition)

What are not considered statements?

Comments, class headers, method headers, and braces

This is run using a source code file as input.

Compiler (How does it run?)

A program that translates source code into an executable form:

Compiler (What is it?)

What creates another file that holds the translated instructions?

Compiler(What does it create?)

/ means

Division- binary - Ex: salePrice = original / 2;

___BLANK___also called double precision (15 decimal points) floating-point numbers.

Double

Literals cannot contain what?

Embedded currency symbols or commas.

What do most compilers translate source code into?

Executable files containing Machine code

(T/F) Identifiers may be any of the Java reserved keywords.(Why)

False

(T/F) Java applications don't need to have a main method.(Why)

False

___BLANK_____ also called single precision (7 decimal points) floating-point numbers.

Float

In Java there are two data types that can represent floating-point numbers. What are they?

Float and double

Integers embedded in java source code are called?

Integer literals

What is another name for JVM?

Interpreter

What language is a strongly-typed language.

Java

Java programming statements are?

Source code

What has a .java file extension?

Source code files

The Java compiler translates a Java source file into a file that contains what type of instructions

byte code instructions

Name all the integer data types

byte, short, int, long

\r

carriage return - cursor goes to the beginning of the current line, not the next line

Java Reserved Keywords - c

case, catch, char, class, const

Identifiers are programmer-defined names for:

classes, variables, methods

Java Reserved Keywords - d

default, do, double

The default type for floating point literals is:

double

\\"

double quote - causes a double quotation mark to be printed

Java Reserved Keywords - e

else, enum, extends

When floating point numbers are embedded into Java source code they are called?

floating point literals.

Data types that allow fractional values are called?

floating-point numbers

1.7 and -45.316 are examples of what type of numbers?

floating-point numbers.

Java Reserved Keywords - g

goto

Java Reserved Keywords - i

if, implements, import, instanceof, int, interface

How must all Java programs be stored ?

in a file with a .java file extension.

Java Reserved Keywords - L

long

Example of Data type conversion

long i = short short i = long (X) - not allowed

Java Reserved Keywords - n

native, new, null

\n

newline

A .java file may contain many classes but may only have how many public classes?

one public class.

Java Reserved Keywords - p

package, private, protected, public


Set pelajaran terkait

Elements name, symbols, and Ionic charges

View Set

final heme review, quiz and exam questions

View Set