12.
After
compiling your java files, Symantec Cafe generates class files with the same
names. Which is the correct explanation about the class files.
A. Class file is ASCII(text) file that we can understand the program.
B. Class file is bytecode file that we cannot understand but computers can.
C. Class file is HTML file that can run in Browser applications (NetScape,
InternetExplore).
D. Class file is application execute file to run application by double clicking
the file.
13. To display a Button with a size of
30x30 at position 100, 100 I need to do the following:
Button b = new
Button(Click Here);
b.setSize(30, 30);
b.setLocation(100, 100)
applet.add(b);
What am I missing?
17. If degs
is an angle in degrees, how do we convert it in radians:
A.
Math.PI/180.* degs
B.
180./Math.PI * degs
C.
degs/Math.PI * 180.
D.
Degs/180. * Math.PI
public void action(Event
e, Object o){
. . .
}
public void
drawPoint(Graphics g, double x, double y){
}
public void
fuzzyShape(Graphics g){
for(int
i=0; i<10; i++)
g.drawLine(0, i*10, 100, i*10);
for(int
j=0; j<10; j++)
g.drawLine(j*10, 0, j*10, 100);
}
1. Which
program is to generate a random integer between 100 and 100?
A. int a = (int)(Math.random()*100.) - 100;
B. int a = (int)(Math.random()*200.) - 100;
C. int a = (int)(Math.random()*200.)-(int)(Math.random()*100.);
D. int a = (int)(Math.random()*(-100.))+100.;
As we already know Math.random()
creates always positive numbers. To get
a negative range we need to generate random numbers within the positive range
and then subtract enough to get negative numbers. So we first create a range of random numbers between 0 and 200
and then we subtract 100.
The answer is B.
Look at the g.drawString method. The two last arguments are the x and y, which
we have replaced with i and j. The
correct answer is A.
The correct answer is D.
There is no MouseClick.
When i=0 a=1 and then a=1+0=1
When i=1 a=2 and then a=2+1=3
When i=2 a=4 and then a=4+2 = 6
When i=3 a=7 and then a=7+3 = 10
When i=4 a=11 and then a=11+4=15
The
correct answer is D because all the others either affect the values of x and y
or do not assign anything to x and y
A variable name cannot start with a number and cannot
contain any arithmetic operation (+, -, *, /).
The correct answer is D.
9. There is a two
dimensional integer array, which is a 4 by 3 and named a. The data is
a[0][0]=0 a[0][1]=2 a[0][2]=4 a[0][3]=6
a[1][0]=8 a[1][1]=10 a[1][2]=12 a[1][3]=14
a[2][0]=16 a[2][1]=18 a[2][2]=20 a[2][3]=22.
I want to make a new one-dimensional array named b to store the as data. In
other words, the data of b should be
b[0]=0 b[1]=2 b[2]=4
...... b[11]=22.
Which is the correct program?
int[] b = new int[12];
for (int i=0; i<3; i++) {
for (int j=0; j<4; j++) {
//***** Choose one from A, B, C,
and D.
}
}
A. b[i] = a [i][j];
B. b[j*4 + i] = a[i][j];
C. b[i*4 + j]= a[j][i];
D. b[i*4 + j]= a[i][j];
We need to multiply the number of rows and add the number
of columns.
Since i is the number of rows and j the number of columns the correct answer is D
For all the integer numbers between 0 and 99 there are only 10 numbers that when divided have a remainder of 0. These numbers are 0, 10, 20, 30, 40, 50, 60, 70, 80, and 90. The correct answer is C.
One bit that can be turned either on (true) or off (false). Correct is B.
12.
After
compiling your java files, Symantec Cafe generates class files with the same
names. Which is the correct explanation about the class files.
A. Class file is ASCII(text) file that we can understand the program.
B. Class file is bytecode file that we cannot understand but computers can.
C. Class file is HTML file that can run in Browser applications (NetScape,
InternetExplore).
D. Class file is application execute file to run application by double clicking
the file.
A class file is a bytecode file that we cannot understand but computers can. Correct is B.
Button b = new
Button(Click Here);
b.setSize(30, 30);
b.setLocation(100, 100);
applet.add(b);
What am I missing?
applet.setLayout(null);
14. What
does the codes 10, 20, and 30 mean in DXF?
The x, y, and z values.
15. What
does the java object called Vector do?
17. If degs
is an angle in degrees, how do we convert it in radians:
A.
Math.PI/180.* degs
B.
180./Math.PI * degs
C.
degs/Math.PI * 180.
D.
Degs/180. * Math.PI
180 degrees is equal to Math.PI so
degs degrees are equal to Math.PI/180.*degs
Correct is A
public void action(Event
e, Object o){
. . .
}
Handles events and objects in the scene. It is used to handles GUI objects.
public void
drawPoint(Graphics g, double x, double y){
g.drawRect(x, y, 1, 1);
or
g.drawString(., x, y);
}
public void
fuzzyShape(Graphics g){
for(int
i=0; i<10; i++)
g.drawLine(0, i*10, 100, i*10);
for(int
j=0; j<10; j++)
g.drawLine(j*10, 0, j*10, 100);
}