1.
Fill-out the Table below.
Data type
short
char
Value
25
[10]
Declarations and assignment
short smallNumber = 25;
true
“My name is Bill”
7789.8
float num = 36.2f;
Indicate whether the following statements are TRUE or FALSE
[10]
A) Strings, char and double areall examples of primitive data types in Java.
B) In Java, the identifiers student, Student, and sTudentareall different.
C) Every source file must be named the same as the class declaredin the file
D) After an Array is declared the size can easily be changed.
E) The == operator can be used to compare twoString objects.
F) One array in the Java programming language has the ability to store many different types
of values.
G) For the expression (y >= || a == b) to be true, at least one of (y >= z) or (a == b) must be
true.
H) Consider the statement examAdmission = (score >= 50) ? "Allowed" : "Denied"; then
the value of examAdmission is Denied, if score = 49
1) The statementif(!allowed) will evaluate to false when allowed = true
J) The Java + operator is used for both string concatenation and addition.
What is the difference between the following:
A) Compiler and assembler
[3]
B) Assembly language and Machine language
[3]
) Primitive and Non-Primitive data types
[3]
Wh at is the output of the following program and showall your workings?
[6]
public class Exam_Q4
a{
public static void main(String[] args)
Ej
{
System.out.println (mystery (5));
}
public static int mystery(int n)
{
if (n <= 1)
return _;
else
return ( mystery(n - _) +n);
}
2|Page