JAVA

Description

Flashcards on JAVA, created by Lulu__ on 31/03/2014.
Lulu__
Flashcards by Lulu__, updated more than 1 year ago
Lulu__
Created by Lulu__ over 10 years ago
305
1

Resource summary

Question Answer
Object-Oriented Programming Software dvpmt technology conceptualised as a group of objects working together
Bytecode Format Java prgms are transformed into - can be run by any computer with a JVM
Platform neutrality A program's ability to run w/o modif in different computing enviroinment
Java Virtual Machine (JVM) Device installed on a computer to run Java bytecode
Procedural Programming Programs are made of a series of instructions carried out in a sequence - tailored to a computer's manner of doing things
Object A self-contained element of a prgm representing a specific group of features & designed to accomplish specific tasks
Class Template used to create an object - objects created from the same class have similar features
CLASS = ? model OBJECT = ? Class = ABSTRACT model for a CONCRETE object
Instantiation Process of creating an object (instance) from a class
Attributes of a class The data that differentiates one object from another; are used to describe/define objects from that class
Attributes are defined by ? VARIABLES
Variables Places to store information in a computer prgm
Instance variables or Object variables Attributes that have values that differ from one object to another; define an attribute of a particular object
Class variable Attribute of an entire class and all of its instances - only one value is stored no matter how many objects created
Behaviour of a class The things that a class of objects can do to themselves and other objects, implemented by methods
Methods (~functions or subroutines in other prgming languages) Group of related statements in a class that perform a specific task (on their own or other objects) // Perform ONE task if well-designed
Instance methods used when? Used when working with an individual object of the class
Class methods apply to? Apply to a class ITSELF
a String object A group of letters, nbrs, punctuation, and other characters
an int a numeric integer value
a float a floating-point number
Inheritance Mechanism that enables one class to inherit all the behaviour and attributes of another class, new class must only define how it is different from existing class
Subclass A class inheriting from another class - all the attributes and behaviour of their superclass
Superclass The class that gives inheritance
Top of the Java Class Hierarchy The class Object
The class Object The most general class in the hierarchy - all classes inherit from this superclass
Subclassing Mechanism for creating new classes as the differences between those classes and their superclass
Default superclass Class Object
Overriding Preventing a superclass' method from being used by creating one in the subclass w/ same name, return type, & arguments // the 1st method def found going bottom up is used
SINGLE inheritance Each Java class can have ONLY ONE superclass (but multiple subclasses)
Interface A collection of methods indicating a class has some behaviour in addition to what it inherits from its superclass - methods are not defining behaviour in interface, needs to be done in the class
Package A way to group related classes & interfaces
Default package java.lang
\n new line
Statement Simple command causing something to happen
Expression Statement producing a value
Return value Value produced by a statement
Block (block statement) A group of statements
Variable Place where info can be stored while a prgm is running, and that can be changed at any point
3 kinds of variables Instance Class Local
Local variables Used inside method def, or even smaller blocks w/n a method - cease to exist afterwards
Equals sign "=" To assign a value to a variable
Byte 8 bits -128 - 127
short 16 bits -32,768 -32,767
int 32 bits +/-2x10^9
long 64 bits +/- 9 x 10^12
Floating-point numbers Numbers w/ a decimal point
Float 1.4E-45 to 3.4E38
Double Even more precise than float
System.out.print()/println() method called to display strings and other info to the output device - takes a single argument ("string") or several, ("string" + variable)
difference btw print() & println() print() does not finish line with a \n character
Single line comment //comment
multi line comment /*comment *commen */!!!!!!!!!!
Javadoc comment Official documentation on how class and methods work, /** ... */
Literals Any nbr, text, or other info directly representing a value
type long Any integer literal larger than an int can hold (but L after said literal to indicate its long type)
Octal numbering prepend with a 0
Hexadecimal numbering Ox...
Binary numbering 0b..;
Type of floating-point literals All double
exponents e or EE ex: double x = 12e22
Underscore in integer literals Make it more readable: int jackpot = 3500000 int jackpot = 3_500_000
Concatenate Link two things
"new" op to create a new object of class type, class name follows new
a constructor special way to create a new instance of a class: it initialises the new obj and its variables, creates any other objs this obj needs, and performs any other op needed to initialise the obj
Dot notation Form of addressing in which an instance or class variable has 2 pts: - A ref to an obj or class (L side) - A variable (R side)
Reference An address that indicates where an object's variables and methods are stored
Casting Process used to convert a value from one type to another
Object wrapper Class used instead of primitive data type (ex: Integer, Double)
parseInt() Class method of the Integer class o convert a String to a numeric type
autoboxing automatically converting a primitive type to an object
unboxing automatically converting an object to a primitive type
Arrays A way to store a list of items w/ same primitive type, class, or common parent class - items are indexed
Array variable It indicates the object or data type that the array will hold and the array's name
Scope of a variable Part if the java prgm where the variable exists and can be used
a conditional statement Executed only if a specific condition is met
Ternary (trois) or conditional operator Alternative to if and else kwords that can return a value instead of executing a statement
For loop Repeat a statement until a condition is met
Declarative languages What but not necessarily how it should be don
Imperative languages Specify both what and how to do something
Changing the size of an Array 1) Create a new bigger array 2) Copy the elements across 3) Delete the old array $$$
Creating an array 1) float farray[] = new float[21] or 2) float[] farray = new float[21] Needs to specify size & type
Function prototype in Java (return type) function(type arg1, type {…body…} ex: int myfun(int a, int b) {…}
Void procedure A procedure simply manipulating some internal state, and thus not returning anything
Modularity BREAK BIG PROBLEMS IN Each class represents a sub-uni of code that can be developed, tested, and updated independently from the rest of the code
Encapsulation (Information/Implementation Hiding) A class should expose a clean interface that allows full interaction with it, but should expose nothing about its internal state (every field should be private by default) HELP minZe coupling and maxZe cohesion
Coupling Refers to how much one class depends on another
High coupling is.. BAD because it means changing one class will require us to fix up lots of others
Cohesion Qualitative measure of how strongly related everything in the class is
Access Modifiers Set access levels for classes, variables, methods, and constructors
Advantages of Immutability - Easier to construct, test, and use - Can be used in concurrent contexts (can be shared between threads w/o worrying about contention issues) - Allows lazy instantiation
How do you "create" immutability in Java? - Make all states private - Make state final (which tells the compiler the value never changes once constructed) - Remove setters methods: no methods should try to change any internal state
Advantages of static methods - Easier to debug as only depends on static fields - self documenting - compiler can produce more efficient code since no specific object is involved
This (keyword) Provides a reference to the current object, can only be used in a class method
super (kword) Gives access to the direct parent (one step up the inheritance tree)
Static polymorphism When we refer to an object via a parent type and both types implement a particular method, we do not know which method to run DEFAULT: run the parent method
Early-binding When we decide at compile-time how to resolve our static polymorphism issue
Show full summary Hide full summary

Similar

Java Week 5 Object Oriented Programming
Troy Bowlin
Java Practice 1
Ummm No
Java Practice 2
Ummm No
Servion - Java Questionnaire
rohit.benedict
Java Core. Basics
Gadget
Programming Review
Shannon Anderson-Rush
Useful String Methods
Shannon Anderson-Rush
Programming in Java
Faheem Ahmed
Object Oriented Programming Concepts
Cmagapu
Herencias de clases
Manuel Espin