JAVA - CS 1400

Ace your homework & exams now with Quizwiz!

Method Names -

All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. Example public void myMethodName()

What is a computer System?

All the components necessary to run a computer

What is a nested loop?

An inner loop that's inside an outer loop.

Which part of the PC performs calculations needed in a Java program?

CPU

What does CPU stand for?

Central Processing Unit

Class variables:

Class variables are variables declared with in a class, outside any method, with the static keyword. A class can have any number of methods to access the value of various kinds of methods. In the above example, barking(), hungry() and sleeping() are methods.

A ____________ is a question whose answer is either yes or no.

Condition

Creating an Object: What are the three steps?

Declaration Instantiation Initialization

Instance Variables -

Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

Class Names -

For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example class MyFirstJavaClass

Which of the following is a compiled java file

Hello world.class

What do the following abbreviations mean? a. I/O: b. CPU: c. RAM: d. GHz: e. MB:

I/O: Input/Output devices CPU: Central Processing Unit or processor RAM: Random Access Memory or main memory GHz: gigahertz = billions of cycles per second MB: MegaBytes = millions of bytes

Write an example of a Boolean if statement:

If (answer == 7)

Instance variables:

Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.

What does the Java Virtual Machine do?

It translates bytecode into object code.

Which of the following runs java programs

JVM- Java Virtual Machine

JVM stands for:

Java Virtual Machine

What does JVM stand for and what does it do:

Java Virtual Machine, turns java byte code into object code.

public static void main(String args[]) -

Java program processing starts from the main() method which is a mandatory part of every Java program..

What is the correct order for the Java compilation process?

Java source code -> compiler -> bytecode -> JVM -> object code

List three types of Variables you will see in JAVA...

Local Variables Class Variables (Static Variables) Instance Variables (Non-static variables)

What happens in an infinite loop:

Loop never terminates

Object -

Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.

What is pseudocode?

Pseudocode is an informal language that uses regular English terms to describe a program's steps.

What is the difference between Psuedocode and actual code?

Psuedocode is an informal version of code. Anyone should be able to read it. It just writes out the process of a program.

What are the 3 main types of algorithms?

Psuedocode, flowcharts, tracing

Write the "Hello World" program,with proper syntax:

Public class Hello { public static void main (String[]args) { System.out.println("Hello world!"); } }

What do the following symbols indicate on a flow chart? Rectangle Circle Arrow Diamond

Rectangle - Input or print statement Circle - Beginning or Ending Arrow - Diamond - Answer

What are three types of control flow?

Sequential Conditional Looping

What are three types of control flow?

Sequential, conditional, and looping

The Java compiler translates from _________ to __________.

Source code; Bytecode

Write a line of pseudocode that tells the computer to assign distance divided by time into a speed variable.

Speed <- distance / time

How do you print something out in java?

System.out.print (Object);

What is the println statement?

System.out.println();

What is not a type of input device?

Telephone modem

Instantiation:

The 'new' key word is used to create the object.

Initialization:

The 'new' keyword is followed by a call to a constructor. This call initializes the new object.

Local variables:

Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.

What is the point of using pseudocode?

Writing informal descriptions of algorithms.

A pictorial representation of a program's logic is also known as:

a flowchart

What is a Program?

a. instructions on how to make a cake b. a Algorithm c. a funny word d. all the above ans: d

Which of the following is not part of the program development process: a. renaming b. Designing c. Testing d. Maintenance e. Writing pseudocode.

a. renaming

Access Modifiers:

default, public , protected, private

Non-access Modifiers:

final, abstract, strictfp

Write an if statement that prints "You get an A!" if a variable (double grade) is 90 or higher. You only have to write the if statement.

if (grade >= 90) { System.out.print("You get an A!"); }

Write a valid "if, else if" example using a student's grade to so how you might print an A for 90 percent and above, B for between 80 and 90 all the way to anything under a 60 being and F.

if grade >= 90 print "A" else if grade >= 80 print "B" else if grade >= 70 print "C" else if grade >= 60 print "D" else print "F"

What kind of data would variable named weight normally hold?

int

What would you type into command prompt to run a program called HelloWorld.java after it has already been compiled?

java HelloWorld

Code an example of class for a dog

public class Dog{ String breed; int age; String color; void barking(){ } void hungry(){ } void sleeping(){ } }

Code Hello World Program

public class MyFirstJavaProgram { /* This is my first java program. * This will print 'Hello World' as the output */ public static void main(String []args) { System.out.println("Hello World"); // prints Hello World } }

Code an example of a class using a puppy

public class Puppy{ public Puppy(String name){ // This constructor has one parameter, name. System.out.println("Passed Name is :" + name ); } public static void main(String []args){ // Following statement would create an object myPuppy Puppy myPuppy = new Puppy( "tommy" ); } }

Provide an appropriate variable name for a variable that holds the total number of students.

totalNumberOfStudents

What is Object Code?

*Also referred to as machine code * A set of Binary- format instructions that van be directly run by a computer *Written in binary so that the computer understands it.

Which of these things is not like the other: a. Assignment operator b. = c. <- d. ==

==

What does the diamond in a flow chart represent?

A Question

Class -

A class can be defined as a template/blue print that describes the behaviors/states that object of its type support.

What is a variable?

A container that holds a value.

Methods -

A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed

What is source code?

A set of instructions written in a programming language.

What is an algorithm?

A step-by-step procedure for solving a problem.

Declaration:

A variable declaration with a variable name with an object type.

Where is a while loop's terminating decision made?

A while loop's terminating decision is made at the beginning of the loop.

Which is FALSE: a. It is possible for a while loop to have an infinite number of iterations. b. It is possible for a while loop to have zero iterations. c. A while loop's terminating decision is made at the end of the loop. d. After a while loop ends, the next thing to execute is the first statement after the end of the loop.

A while loop's terminating decision is made at the end of the loop.

Java Identifiers:

All Java components require names. Names used for classes, variables and methods are called identifiers. *All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). *After the first character identifiers can have any combination of characters. *A key word cannot be used as an identifier. *Most importantly identifiers are case sensitive. *Examples of legal identifiers: age, $salary, _value, __1_value *Examples of illegal identifiers: 123abc, -salary

Identify two important computer input devices.

The keyboard and the mouse

Describe what this statement does: print "user name = " + userName

The statement prints out what is exactly in the quotes and prints the current value of username

What is the Java Virtual Machine?

Translates the program's bytecode to object code. It translates Java bytecode into object code.


Related study sets

The Greek Gods and Goddesses Study Guide

View Set

PN Adult Medical Surgical Online Practice 2020 A

View Set

Intro to business SmartBook Ch. 12, 11 ,and 7

View Set

Outdoor Pursuits Chapter Reviews

View Set

HIT 1.2 #B (Select from the following body systems to match the organ or tissue that is found within the systems.)

View Set

Prep U / (COMBINED) - Chapter 30: Perioperative Nursing

View Set