Building Blocks Flashcards

1
Q

what is object?

A

An object is a runtime instance of a class in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are the two main elements of class?member of class?

A

methods and variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the keyword?

A

calls a word with special meaning

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

meaning of public and class keywords?

A
public--  class can be used by other classes
class- is created class with name "toy class"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the void?

A

it is a return type and no need to return value for that method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the method signature?

A

a full declaration of method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

public int numberVisitors(int month)

A

int-return type,
numberVisitor-name of the method
(int month)- parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

comment types

A
//--one line,
/* * * /*-- multiple line comment
/**  * * .  /*- javadoc comment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

does it proper class

A
class toy { 
String str;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

does it proper class?

A
public class phone{
}
class smartPhone{
String name;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the main() method?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

java file extension

A

.java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

bytecode extension?

A

.class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

the correct main method parameters?

A

String[] args, String args[] or String… args;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how could be create an objects?

A

by using constructors—- Random random=new Random();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Random random=new Random();

A
Random random----declare the variable
new Random()---- create an aobject on the heap memory
17
Q

two main specs for constructors?

A
the name of constructor is same as class name,
no any return type in constructors,
18
Q

what is the code block?

A

between bracies–{ }

19
Q

what is the code block?

A

between bracy–{ }

20
Q

instance initiliazier?

A

when count it, just in the methods,

21
Q

what are the variables?

A

primetives and reference type

22
Q

what are pirimitives?

A

boolean, char, short, long, int, long, float, double store in the stack memeory and store values always

23
Q

what is the reference types?

A

it is a handle to refer an object on the heap.

24
Q

difference between primetives and reference types

A

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

25
Q

what is declearing?

A

String str, int numHome;

26
Q

what is initiliazing?

A

String str=”maer”;

27
Q

does it work

A

int num, String value;

28
Q

important identifier names rules in Java?

A

must begin with a letter or the symbol $ or _.
Subsequent characters may also be numbers.
cannot use the same name as a Java reserved word.

29
Q

bad example for identifier names?

A

3DPointClass // identifiers cannot begin with a number hollywood@vine // @ is not a letter, digit, $ or _ *$coffee // * is not a letter, digit, $ or _
public // public is a reserved word

30
Q

local variables

A

define in method
initiliazed before use
not have a default value

31
Q

instance variables

A
Instance variables are also called fields.
variable is a class variable if it has the static keyword in its declaration
32
Q

instance and class variables

A

Instance and class variables do not require you to initialize them. As soon as you declare these variables, they are given a default value.

33
Q

order by package and import and class

A
package structure; // package must be first non-comment import java.util.*; // import must come after package public class Meerkat { // then comes the class
double weight; // fields and methods can go in either order public double getWeight() {
return weight; }
double height; // another field – they don't need to be together
34
Q

class structure in the order

A

multiple classes can be defined in the same file, but only one of them is allowed to be public. The public class matches the name of the file.

35
Q

Benefits of Java

A

Java is an object-oriented language, which means all code is defined in classes and most of those classes can be instantiated into objects.

36
Q

Benefits of Java

A

Encapsulation Java supports access modifiers to protect data from unintended access and modification.