Unit 1 Flashcards
Naming convention of a class
Upper camel case “ BonJour”
Writing convention of an interface
uppercase start and should be an adjective “Adjective”
Writing convention of a method
lower camel case “bonJour”
Writing convention of a variable
lower camel case “bonJour”
Writing convention of a camel case
all lowcase “mypack”
Writing convention of constants
ALL CAPS “BONJOUR”
What is main
a method
What is public
Access specifier (control the visibility)
What is static
To call main w/o instantiating
void?
Return type
args
name chosen for this String array
What is the range of a byte
-128 ~ 127
What happens when you pass the limit of a datatype
For into it either creates an over flow or an underflow where it goes to the maximum or or minimum number
int i=5;
int j=i++;
int g=5;
int k=++g;
j=i then i+1
g=g+1 then new g=k
True or False: Java gives a warning whenever a variable isn’t used.
True, not an error warning.
What is the difference between char in Java vs char in C/C++?
In C/C++, char is an integer type (8 bit wide). But Java uses Unicode (UTF-16) to represent them. In Java,
char is of 16 bit type.
Vrai ou faux? You can convert double to int in java and the reverse.
Faux. It is an error, unlike C++ it won’t round up or down. but the reverse is true. Same thing with boolean…its not allowed.
public class Main {
public static void main(String args[])
{
int x=2;
int y=x++*3;
System.out.println(x+” “ +y);//15.0
}} What's the output?
3 and 6
What does ~ do ?
if 9,then -10
double result= ++y*x/y;
the second y is the new y
System.out.println(a+b+” “+a+b);
System.out.println(a+b+a+b);
19 712
38 so unless there is a string it adds
Continue skips to the iteration and breaks skips the whole iterations
Try it!