HNDIT1209 Object Oriented Programming I Programming in JAVA
HNDIT1209 Object Oriented Programming I Programming in JAVA
HNDIT1209 Object Oriented Programming I Programming in JAVA
I~ I !/~~!~/TUTE OFADVANCEDTECHNOLOGICALEDUCATION
(Established in the Ministry of Higher Education, vide in Ad No. 29 of 1995)
ee
Answer five (05) questions only No. of pages : 07
All questions carry equal marks. Time : Three (03) hours
Question 01
al
(i) Write the default value of given data types in JAVA.
a. byte
m
b. int
c. String
co
d. boolean
(04 marks)
rin
a.
int x = 2;
IT
b.
System.out.print("\"Hello\\\n Ann!");
AT
c.
int break = 3;
System.out.print( --break);
(06 marks)
(iii) Evaluate the following expressions for x=Z, y=5 and z=9
a. x + y * 5-z
b. (zJx )+ y/2 + xi2
c. z%5 + 5*3+1
(06 marks)
(04 marks)
(Total 20 marks)
ee
Question 02
al
(i) Rewrite the given code segment with only one if statement.
if(attendance >= 80)
if(assignmmentMarks >= 40)
m
eligibility = true;
(04 marks)
(06 marks)
(iv) Write a complete JAVA program to display Summation of Even numbers between 0 and
100 using a/or loop. (0 and 100 are not included)
( 06 marks)
(TotallO marks)
2
HNDIT - HNDITl2091lT 2001 - Object Oriented Programming I Programming in JAVA 2015
r :,J'
Question 03
a. Create a String array named days which can hold 7 String values.
(02 marks)
b. Create a char array named vowels and initialize it. (Either capital letters or simple
letters)
(02 marks)
ee
c. Print the second element in the following integer array. Array name is score.
al
(02 marks)
d. Replace the value 7 with the value 9 in the following integer array. Array name is
score.
m
co
(02 marks)
(iii) Write answers to question a to c by considering the given JAVA code segment.
System.out.printlmx.cbareusj);
IT
(02 marks)
h. Write the line of code to get the number of characters in the above string.
(02 marks)
AT
(02 marks)
3
HND1T - HNDITI 209 lIT 2001 • Object Oriented Programming I Programming in JAVA 2015
(iv) Consider the given code segment.
Write the code segment to compare two variables (x and y). If x and y variables have same
value display a message "same" otherwise display a message "different".
(04 marks)
ee
(Total 20 marks)
al
Question 04
m
You are asked to design a cylinder class using JA VA language to keep records on
cylinders manufactured by a company. The company needs to store the cylinder color,
radius and height for each cylinder. Design the cylinder class with following
properties.
co
a. Encapsulated instance variables: color, radius and beight.
(03 marks)
rin
(04 marks)
IT
(03 marks)
d. Public displayVolume method to calculate the volume of the cylinder and print it.
AT
e. Write the code segment to create an instance of the cylinder class passing following
values for the instance variables.
(02 marks)
4
HNDIT - HNDITl209 / IT 2001 - Object Oriented Programming / Programming in JA VA 2015
(ii) What is an Exception in JAVA?
(02 marks)
(iii) Write a Java code using try catch blocks to handle the exception when trying to access
an array index out of its range.
(4 marks)
(Total 20 marks)
ee
Question 05
al
II Shape contains abstract methods only
}
m
a. Can you create an object using Shape class?
(02 marks)
b. Explain your answer.
co
(02 marks)
(ii) Write a JA VA code segment to design a class named as CheckingAccolint using the
rin
bellow interface. (You are not expected to define body of the Checking.Account class)
(04 marks)
(iii) Write answers to a and b from the given code segment.
II Code here
}
5
HNDIT - HNDITl209 / IT 2001 - Object Oriented Programming / Programming in JAVA 2015
b. What is the name of Sub Class?
(02 marks)
(iv) When methods are overloaded, explain how JA VA would select matching method.
(02 marks)
(04 marks)
(vi) Name a class or an interface which can be used to create a thread in JAVA.
ee
(02 marks)
(Total 20 marks)
al
Question 06
m
(i) You are given App.class applet file. You would be asked to display that in your web
browser 300 pixels width and 250 pixels height screen. Write the suitable HTML tag(s) with
attribute values to display your applet. (You are not expected to write complete HTML file)
co
(04 marks)
(ii) Write a JAVA code segment to draw a Line between (l0, 10) and (50, 50) coordinates.
(Hint: Use bellow incomplete JA VA code segment)
rin
(06 marks)
AT
6
HNDIT - HNDIT! 2091 IT 2001 - Object Oriented Programming 1 Programming in JAVA 2015
· I
ee
(10 marks)
al
(Total 20 marks)
m
co -END-
rin
IT
AT
7
HNDIT - HNDITI 209/ IT 2001 - Object Oriented Programming / Programming in JAVA 2015
AT
IT
rin
co
m
al
ee