Java

Description

reminders for basic concept in COSC class
Anika Patry
Flashcards by Anika Patry, updated more than 1 year ago
Anika Patry
Created by Anika Patry over 7 years ago
16
0

Resource summary

Question Answer
Procedural tells the computer how to preform task in a series
Object oriented driven by an even or user emphasis on code reuse by creating objects (Like Java)
who was java invented by? james gosling sun micro-systems
what are the types of programming error, and how many are there? 1)syntax errors; 2)semantic errors 3)Run Time Errors:
what is an algorithm? an algorithm is a piece of rough draft/ plan of the code you are going to write.
what are the components of an algorithm? how many components are there? there are 7 define the problem, inputs, outputs, assumptions, hand cals, general, detailed ver.
what are the two types of algorithms? pseudo code and flow charts
name the primitive data types byte, int, short, long, double, float, char, boolean
what is the size of a byte data type? 8 bit storage 1- 127/128
what is the size of a long data type? 64 bit storage hold numbers 2^63 and 2^63 -1
what is the size of a short data type? 16 bit storage hold number 1/0 - 32768 and 32767
what is the size of a int type? 32bit storage hold numbers 1 - 2^31 and 2^31 - 1
what is the size of a float type? 32 bits values between -3.4E38 to 3.4E38(6 to 7 digits of precision)
what is the size of a double type? 64 bits values between -1.7E308 to 1.7E308(14 to 15 digits of precision)
what is the size of a char type? 16bits holds one character
what is the size of a boolean type? 16bits true or false values
what is a literal? They are constant values that can be assigned to a variable or used in an equation
what is implicit cast? automatic promotion from a lower data type to a higher data type. The compiler does the work, and nothing is required from the programmer.
what is an explicit cast? casting from a higher data type to a lower data type, explicit casting with most likely result in the loss of data. Situations where an explicit cast is required will be a syntax error unless the programmer does the explicit cast.
what is a named constant? This is like a variable except the value stays constant. Constants give literal values that have a specific meaning a name so that we can use it in the program.
how do you declare a named constant? Directly after the public class public static final ex/ public static final int( or var type) NUMB=30;
what are the two types of system outputs that we can use? 1) Println - displays to the user and moves to the next line on the display 2) Print - displays information and stays on the same line
how do we receive input from a user? we can prompt for input by using the scanner function.
why dont we use system.in? it is very difficult to work with
what do we use instead of system.in? we use the scanner packet
how can we use the scanner function in the java code? we will have to import it : import java.util.Scanner; we will also have to rename it, Scanner input(new scanner name) = new Scanner(system.in);
how can we different data types from scanner? scannername.next[var-type]();
what type of data is a string? class data type
how do you declare a string variable? String "this is the string variable"
what method tells you if a string is empty? isEmpty();
what method extracts a part, or parts of a string? Substring( beginIndex) substring(beginIndex, endIndex)
how would you create a new string in all caps? how about all lowercase? toUpperCase() ; toLOWERCase() ;
how can you check if a string equals another use the equals method
what is the order of operations that java follows? () ++ -- ! * / % + - <, > , >= , <= == != && ||
what is a decision statement? in java it is if's, and else if's
what is the proper syntax of an if statement? if ( Boolean expression ) { then statement(s) }
can you have an if statement in another if statement? yes.
if you have an if statement with in another what is it called? a nested if statement
how would you scan a char data type with the next function? you cannot use the next function so you will have to use the following: scanner.next.charAt(0);
what is a switch statement? a switch statement is similar to an else if statement. It is also used for mutually exclusive situations
what is the syntax for a switch statement? switch(controlling expression) case label: statement break;
how do you check the validity of inputs with a switch statement? using the default (case
Show full summary Hide full summary

Similar

Useful String Methods
Shannon Anderson-Rush
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Historical Development of Computer Languages
Shannon Anderson-Rush
Java Week 5 Object Oriented Programming
Troy Bowlin
Flvs foundations of programming dba 2
mariaha vassar
Programming Review
Shannon Anderson-Rush
Programming in Java
Faheem Ahmed
COP 1000 - Intro to Computer Programming (Final Exam)
Taylor Walker
Python Quiz
karljmurphy
computer systems and programming quiz
Molly Batch
Think Python
tsilvo2001