Java Programming Final Paper

carenextΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 4 μήνες)

50 εμφανίσεις

Java Programming



Final Paper



Time : 3 Hours


Section A:


Multiple Choice Questions | Answer All Questions | All Questions Carry Equal Marks


[ Marks
2

x 20 =
4
0 ]


01.

_________ is NOT an Object Oriented Programming Language
.

a.

VB 6

b.

VB.net

c.

Java

d.

C#

02.

“A varia
ble is a memory location and the value stored in the variable cannot
be changed during the execution of the program”, about the above state
which is/are correct

a.

True

b.

False

c.

Sometimes true

d.

None of the above

03.

Java Programming Language was invented by _________
_______ of Sun
Microsystems Inc.

a.

James

b.

Jane Joseph

c.

James Gosling

d.

None of the above

04.

Java does support Multiple Inheritance, about the above which statement
is/are correct.

a.

False

b.

True

c.

At special occasions

d.

None of the above

05.

guess the correct output for the g
iven code segment


int x = 9;

int y = x + x


3;

int z = x;

System.out.println(z);


a.

16

b.

13

c.

9

d.

10

06.

Java methods can return values, and when declaring a method sometime the
keyword
void

is

used
, the purpose of this is,

a.

To make the method work fast
er

b.

To make the

method return a value

c.

Indicates that the method does not return any value.

d.

Answers a, and b are correct

07.

In order to create new objects from a class, which of the following keyword is
used?

a.

instan
c
eof

b.

class

c.

new

d.

public

08.

When programming sometimes we need to
store series of characters, in
order to do this we make of the type String, String is a

a.

Primitive type

b.

Reference type

c.

Char type

d.

None of the above

09.

In the given list below which list includes all the data types which are used to
store

only

whole numbers?

a.

in
t , float, boolean, char

b.

int,byte,shot,long

c.

long, short, byte, int

d.

long,double,byte, int,char

10.

about while loop in java
,

which statement is correct

a.

checks the condition at the end.

b.

checks the condition at the beginning.

c.

executes the loop body at least onc
e.

d.

None of the above

11.

out of the following variable

name
list which list contains all correct
ly
declared variables

a.

$alary, total, amount, 15thValue

b.

count, new, void, school

c.

firstName, lastName, civil#status

d.

none of the above

12.

Arrays are static data structure
s in Java, above statement is true or false

a.

True

b.

False

13.

An array can contain multiple values belonging to different data types

a.

True

b.

False

14.

___________ the property is used to find out how many elements are there
in an array.

a.

getSize

b.

findLength

c.

length

d.

size

15.

Wh
en you want to develop GUI programs in java the AWT package is used,
you need to make available this package in the program, out of the following
,

which statement does this correctly.

a.

imported java.awt.Applet.*;

b.

imports java.awt.*;

c.

import java.awt.*;

d.

impo
rt java.applet.Applet;

16.

Out of the following actions which can be handled with ActionListener

a.

Clicking a Button

b.

Typing Text inside a TextField

c.

Adjusting a scrollbar

d.

Selecting an item from a Choice control

17.

A method can have any number of incoming parameters.

a.

True

b.

False

18.

javac is _____________________

a.

is the java compiler

b.

is the java interpreter

c.

is not a command line tool

d.

none of the above

19.

When assigning a large primitive variable to a small primitive variable
_________ casting should be done,

a.

Implicit

b.

Explicit

c.

Explosive

d.

Expected

20.

If a java application needs to be executed which method is a must, and in this
method only the

Java program’s
execution starts

a.

Main(String[] args)

b.

public void main(string[] args)

c.

public static void main(String[] args)

d.

public void action
Performed(ActionEvent e)


Section B :

Marks [2 x 5 = 10]

Question 01.

Briefly explain the following methods
, use example code if appropriate

a.

getText()

b.

addActionListener(this)

c.

parseFloat()

d.

parseInt
()

e.

setLayout()

Marks [ 10 ]

Question 02.

The program given

bellow was written by a student and it contains lots

(7)

of errors
re
-
write the code by fixing the errors.


Public class Example Pro{


Public static void main(string[] args)}



int x,y,z;



x=20



y=x;



z=x * y;




for(int i=0; i<10;


i+){




System.out.
println(z);



}


}

{

Marks [20]

Question 03.

Create the following Java Applet to enter employee work details such as Hours
worked and hourly rate
, calculate the gross wage

then
find

out the
tax amount
,
then find the
net pay

display the details in the relev
ant text fields

[TAX


is calculated as follows]


gross wage >= 25000.00


10%


gross wage >= 20000.00


8%


gross wage >= 15000.00


5%


gross wage < 15000.00


3%






Employee No

Tax amount

Hours Worked

Hourly Rate

Gross Pay

Net Pay

t1

t2

t
3

t4

t5

t6

Calculate

Clear