java5
java5
/Seat No_______________
MARKS
Q.1 (a) Answer in one word:(one mark for each) 03
I. Which integral type in Java has the exact range from -
2147483648 (-231) to 2147483647 (231-1).
II. The software for developing and running Java
programs.
III. It is similar to machine instructions but is
architecture neutral and can run on any platform that has
a Java Virtual Machine (JVM).
(b) Write a program that reads an integer and adds all the 04
digits in the integer. For example, if an integer is 932, the
sum of all its digits is 14.
Hint: Use the % operator to extract digits, and use the /
operator to remove the extracted digit. For instance, 932
% 10 = 2 and 932 / 10 = 93.
int m= 1;
int s= 0;
for (int i = 0; i < nums.length; i++) {
if (nums[i] > m) {
s = m;
m = nums[i];
} else if (nums[i] > s && nums[i] != m) {
s = nums[i];
}
}
System.out.println("s is: " + s);
P
A
G
III. int i=1,j=0,k=0;
if (i > k) {
if (j > k)
System.out.println("i and j are greater than k");
}
else
System.out.println("i is less than or equal to k");
IV. int x = 3, y = 3;
switch (x + 3) {
case 6: y = 1;
default: y += 1;
}
System.out.println("y is " + y);
V. class HelloWorld {
public static void main(String[] args) {
int[] numbers = new int[1];
numbers[0]=0;
m(numbers);
System.out.println("numbers[0] is" +
numbers[0]);
}
public static void m(int[] y) {
y[0] = 3;
}
}
VI. StringBuffer s1 = new StringBuffer("Complete");
s1.setCharAt(1,'i');
s1.setCharAt(7,'d');
System.out.println(s1);
VII. int Integer = 24;
char String ='I';
System.out.print(Integer);
System.out.print(String);
P
A
G
(b) i. Analyze following code pieces and write the 04
output/error and briefly justify output:
public class Test {
public static void main(String[] args) {
new Person().printPerson();
new Student().printPerson();
}
}
class Person {
public String getInfo() {
return "Person";
}
P
A
G
Q.4 (a) How do keyword throw differ from throws in Exception 03
handling?
(b) Differentiate between a byte oriented and a character- 04
oriented stream.
(c) Explain binary I/O classes. Demonstrate java file I/O with 07
any I/O class to read a text file.
OR
Q.4 (a) Compare JavaFX with Swing and AWT. 03
(b) i. List any four UI controls in JavaFX. 04
ii. List any two Panes for Containing and Organizing
Nodes
(c) Write a program to demonstrate GUI application 07
development using JavaFX.
Q.5 (a) What are the differences between ArrayList and 03
LinkedList? Which list should you use to insert and delete
elements at the beginning of a list?
(b) What is Java Collection Framework? List four collection 04
classes?
(c) Give the name of class or interface that provides following 07
facility (Do not elaborate)(one mark for each)
i. Dynamic array to store the duplicate element of different
data types. It maintains the insertion order.
ii. Implements the last-in-first-out data structure.
iii. Implements the first-in-first-out data structure.
iv. Implements the first-in-first-out data structure and it
holds the elements or objects which are to be processed by
their priorities.
v. It represents the unordered set of elements which
doesn't allow us to store the duplicate items.
vi. It is a red-black tree-based implementation. It provides
an efficient means of storing key-value pairs in sorted
order.
vii. It allows us to store key and value pair, where keys
should be unique.
OR
Q.5 (a) Explain thread life cycle. 03
(b) What is the package? Explain steps to create a package 04
with example.
(c) Declare a class called Employee having employee_Id and 07
employee_Name as members.
Extend class Employee to have a subclass called
SalariedEmployee having designation and
monthly_salary as members. Define following:
- Required constructors
- Methods to insert, update and display all details of
employees.
- Method main for creating an array for storing these
details given as command line arguments and showing
usage of above methods.
***********
P
A
G