Building Blocks Flashcards
what is object?
An object is a runtime instance of a class in memory
what are the two main elements of class?member of class?
methods and variables
What is the keyword?
calls a word with special meaning
meaning of public and class keywords?
public-- class can be used by other classes class- is created class with name "toy class"
what is the void?
it is a return type and no need to return value for that method
what is the method signature?
a full declaration of method
public int numberVisitors(int month)
int-return type,
numberVisitor-name of the method
(int month)- parameter
comment types
//--one line, /* * * /*-- multiple line comment /** * * . /*- javadoc comment
does it proper class
class toy { String str; }
does it proper class?
public class phone{ } class smartPhone{ String name; }
What is the main() method?
A main() method is the gateway between the startup of a Java process, which is managed by the Java Virtual Machine (JVM), and the beginning of the programmer’s code.
java file extension
.java
bytecode extension?
.class
the correct main method parameters?
String[] args, String args[] or String… args;
how could be create an objects?
by using constructors—- Random random=new Random();
Random random=new Random();
Random random----declare the variable new Random()---- create an aobject on the heap memory
two main specs for constructors?
the name of constructor is same as class name, no any return type in constructors,
what is the code block?
between bracies–{ }
what is the code block?
between bracy–{ }
instance initiliazier?
when count it, just in the methods,
what are the variables?
primetives and reference type
what are pirimitives?
boolean, char, short, long, int, long, float, double store in the stack memeory and store values always
what is the reference types?
it is a handle to refer an object on the heap.
difference between primetives and reference types
holds a value, store in stack, not call any methods, never be null, when using equaility copied,
handle to refer the object, in heap, can be null, call any methods, when equality not copied object