In: Computer Science
Mobile Business Programming Exercise
1. Which ones are valid? (Please estimate each one of the following statements)
int x y = 3;
string appName = “Girls Crush”;
float RealNumber = 3.11;
String [3] myUsers = {“Eric”, “Steve”, “Linda”};
ArrayList <String> values = ArrayList <String> ( );
int [ ] income = new int [5];
float abc = 3.22
2. Fill out the blanks
________ (a > b)
{ sum = a+b; }
_________
{ sum = 0; }
3. Fill out the blanks
___________ getTotal (int a, int b)
{
total = a + b;
______________ total;
}
4. Fill out the blanks
___________ method1 (String txt1, String txt2)
{
_____________ comparison;
comparison = txt1.equalTo(txt2);
}
5. What is the final result, given that a = 1, b =2, c =3, and d =5?
a<=d || a>3 || c > d || b < d
6. What is the final result, given that a = 100, b =99, c =93, and d =101?
a<=d && c < 98 && b < d
7. What is the final result of the variable sum, given that a = 100, b =99, c =93, and d =101?
if (a > d || b < c)
{
sum = 100;
}
else
{
sum = 0;
}
8. Fill out the blanks
___________ method2 (String txt1, String txt2)
{
_____________ comparison;
comparison = txt1.equalTo(txt2);
if (comparison)
{
___________ “The two text messages are the same.”;
}
else
{
___________ “The two text messages are different.”;
}
}
1. The valid statements are
float RealNumber = 3.11;
int [ ] income = new int [5];
2.
if (a > b)
{ sum = a+b; }
else
{ sum = 0; }
3.
int getTotal (int a, int b)
{
total = a + b;
return total;
}
4.
void method1 (String txt1, String txt2)
{
boolean comparison;
comparison = txt1.equalTo(txt2);
}
5.
True
6.
True
7.
sum =0
8.
String method2 (String txt1, String txt2)
{
boolean comparison;
comparison = txt1.equalTo(txt2);
if (comparison)
{
return “The two text messages are the same.”;
}
else
{
return “The two text messages are different.”;
}
}
Please let me know in comments if you have trouble understanding any part