Data Declaration and Assignment Practice



Assume that there exist classes for String, MainWindow, and Location. Do the following using correct JAVA syntax.
Answers
1)	Declare an int named myInteger.

2)	Declare a char named mySingleLetter.

3)	Declare a String object reference named helloWorld.

4)	Declare a MainWindow object reference named mainWindow.

5)	Declare a double named myDecimal.

6)	Declare a byte named verySmallNumber.

7)	Declare a float named anotherDecinmal.

8)	Declare a Location object reference named hereIAm.

9)	Declare a short named smallNumber.

10)	Declare a MainWindow object reference named mw.

11)	Declare a long named veryBigNumber.

12)	Declare a MainWindow object reference named mainWin.

13)	Declare an int named myNumber.

14)	Pretend that someone did not read up on their naming conventions,
	and defined a class named "int[]". Declare an int[] object reference
	named arrayOfInts.

Answer the following questions, which asks about the computer state after the following code has been executed. Answers
int a;
double b;
char c;
MainWindow mainWindow;
String s;
String t = "";
15)	What is the value of a?

16)	What is the value of b?

17)	What is the value of c?

18)	What is the value of mainWindow?

19)	What is the value of s?

20)	What is the value of t?
Perform the following assignments. You may assume that the following data has been properly declared: Answers
int a;
int b;
double i;
double j;
char m;
char n;
String s;
String t;
21)	Assign to a the number twelve.

22)	Assign to a the number negative three.

23)	Assign to i the number twelve point eight.

24)	Assign to i the number twelve.

25)	Assign to i the number three point one four one five nive
	two six five three five eight nine seven nine three two
	three eight four six two six four three three eight three
	two seven nine five.

26)	Assign to i the number twenty-two sevenths.

27)	Assign to m the letter f.

28)	Assign to m the number m.

29)	Assign to m the character of 1.

30)	Assign to m the character of !.

31)	Assign to m the character of a single space.

32)	Assign to m the nul character.

33)	Assign to s the String "Hello, World!".

34)	Assign to s the String "A string is anything in quotes.".

35)	Assign to s the String of m.

36)	Assign to s the String of !.

37)	Assign to s the String of a single space.

38)	Assign to s the empty String.

39)	Assign to s the JAVA keyword null.

40)	Assign to a the value of b.

41)	Assign to b the value of a.

42)	Assign to i the value of j.

43)	Assign to j the value of i.

44)	Assign to m the value of n.

45)	Assign the value of n to m.

46)	Assign the value of s to t.

47)	Assign to t the value of s.

Assume that there exist classes for String, MainWindow, and Location. Do the following using correct JAVA syntax.
Answers
48)	Declare an int named myInt and
	assign to it the value seven.

49)	Declare a double named myDouble
	and assign to it the value seven.

50)	Declare an int named myInt and
	assign to it the value eight.

51)	Declare a double named myDouble
	and assign to it the value eight.

52)	Declare a double named myDouble
	and assign to it the value of seven thousand.

53)	Declare a double named expDouble
	and assign to it the value of seven thousand, using JAVA's
	exponential notation for powers of ten.

54)	Declare a double named expDouble
	and assign to it the value of seven thousandths using JAVA's
	exponential notation for powers of ten.

55)	Declare a double named myDouble
	and assign to it the value twenty-nine point three.

56)	Declare an int named copy and
	assign to it the value of an int named source.

57)	Declare a Location object reference named alias and assign
	to it the Location object that is the value of a Location object
	reference named source.