Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
RESEARCH UNIVERSITY
UNIVERSITITEKNOLOGI MALAYSIA
FACULTY OF SCIENCE
FINAL EXAMINATION
SEMESTER I SESSION 2011/2012
CODE
SSP 2333
COURCE
COMPUTER PROGRAMMING
LECTURER
PROGRAM
DATE
18 JANUARY 2012
DURATION
3 HOURS
SSP 2333
Name
Course
Instructions:
a) Answer all questions.
Question 1.
a) Write on the following blank lines two Java keywords for doing
repetitive or iterative computation.
[ 2 marks ]
i) _________________________ ii)
b) Write on the following blank line a Java declaration statement for
creating an array of real numbers that can contain 11 elements.
[ 2 marks ]
d) Write down the Java print statement for printing to screen the
values of the following three variables:
[ 3 marks ]
int i=0;
double x;
String a="yes"
[-1-]
SSP 2333
Question 2.
a)
a
[0]
[1]
[0]
5
3
Table 1
[1]
4
-5
[2]
6
7
[3]
10
9
A)
B)
C)
D)
b)
(i)
[-2-]
SSP 2333
Question 3.
a)
.B=
[2 Marks]
b)
(ii)
Question 4.
a)
b)
[2 marks]
for
what is the
[-3-]
SSP 2333
c)
Question 5.
There are 5 syntax errors in the following java program. Find
those errors and suggest the corrections.
public class maxmin {
public static void main(String args[]) {
doublet] num = new double[10];
int maxnum, minnum;
int j;
num[l]=-2.5; num[2]=0.0;num[3]=1.5; num[4]=7.5;
num[5]=9.2;
num[6]=6.6; num[7]=-10.5; num[8]=20.1; num[9]=3.4;
num[10]=8.3;
maxnum = 0.0;
minnum = 0.0;
fr(j=l; j<=10; j++); {
if (num[j] > maxnum) {
maxnum = num[j];
}
if (num[j] < minnum) {
minnum = num[j];
>
System.out.printf("Number + j + " is " + num[j]);
System.out.printf("Biggest number is %4.If\n",maxnum);
System.out.printf("Smallest number is %4.If\n",minnum);
}
>
[-4-]
SSP 2333
Question 6.
a)
b)
int a = 1 | 2
int
= ((1
| 2)
3 i 5;
* 3) & 5;
int c = l | ( 2 * (3 & 5) ) ;
int
c)
d = 202;
[-5-]
SSP 2333
Question 7.
a)
String StrMassOfObject;
double mO;
StrMassOfObject = jTextField2.getText();
b)
[-6-]
SSP 2333
Question 8.
items
1.5
2.2
3.0
3.9
5.3
6.1
6.8
2.5
4.2
15.9
8.2
9.9
12.5
13.7
Table 2
a)
(x.f
S = ^ for yf<10
=i y.-
b)
Question 9.
The position of an object, m is described by the following equation
of motion:
y(t)=y0+vt+jat2 ,
SSP 2333
Question 10.
import j ava.awt.*;
import javax.swing.*;
import java.applet.Applet;
public class ContohApplet extends JApplet {
JButton btnForce, btnMass, btnAcce, btnClear;
JTextField txtForce, txtMass;
JLabel
lblForce, lblMass;
JPanel
northPanel, centerPanel,southPanel;
JLabel
content
content.setLayout
getContentPane();
(new
BorderLayout());
add(northPanel,
BorderLayout.NORTH);
add(centerPanel,
BorderLayout.CENTER);
add(southPanel, BorderLayout.SOUTH);
}
>______________
a)
b)
c)