Consider the following program, what is the output? (2 marks)
class overload
{
int x;
double y;
void prod(int n)
{
for (int i=1;i<n;i++)
x=x*i
}
void prod(int n, int m)
{
for (int i=n;i<m;i++)
y=y*i
}
overload()
{
this.x = 1;
this.y = 1;
}
}
class Overload_methods
{
public static void main(String args[])
{
overload obj = new overload();
int n = 2;
int m = 4;
obj.prod(n);
obj.prod(n,m);
System.out.println(obj.x + " " + obj.y);
}
}
Which is the following is the correct format for: sum = sum*2? A. sum=*2
B. sum*2
C. sum*=2
D. sum*2=sum
2. Please construct a class in terms of the below description. (5 marks)
HKIT needs to develop a system to keep the students’ profile including the name, student id, the programme enrolled by the student, address of student and age. Student could read and modify his/her profile. Please help construct a Student class for this purpose.
class Student {
//variables (2 marks)
//getter (one getter is ok) (1 mark)
//setter (one setter is ok) (2 mark)
Write if-else statement that outputs
Student must achieve at least 40 in the exam grade and 70% in the attendance in order to pass the module (print out “You pass the module!”). If the student fails the attendance only, the student needs to take classes to make up the attendance (print out ”Please take classes to make up your attendance.”) . If the student fails the exam grade only, the student is eligible to apply re-exam (print out “You are eligible for re-exam”). If the student fails both the exam and the attendance, the student needs to retake the whole module (print out Please retake the module”).
The variables attendance is of type double, and grade is of type int.
if (______________________ ) {
_______________________________________________________
}
elseif (___________________) {
______________________________________________________
}
elseif (___________________) {
______________________________________________________
}
else {
______________________________________________________
}
Write a program reads and store 10 integer elements in an array
Create a Java EE Web application to create a web application about music (songs, tutorials, instruments, etc.)
Functional requirements:
1. Proper UI (5 marks)
At least 2 tables in the database with CRUD feature and Normalization
Find latitude and longitude of utmost 20 countries, ordered by population, with a population greater or equal to the population limit given below and have atleast one currency exclusively for themselves. (countries like Madagascar, Sri Lanka but not India, USA). Use the country details from this dataset.
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Population limit: 15933883
Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit before submitting.
Some animals can scream, others are mute. We will represent the fact of shouting by means of a method displaying on the screen the shout of the animal (Miaou, Wouf ...).
- Write an interface containing the method allowing to scream.
- Write the classes for cats, dogs and rabbits (which are mute)
- Write a program with an array of animals that can scream, fill it with dogs and cats and then make all these animals scream. Describe what is displayed on the screen when this program is run.
A member class has id, name and payment rate. In member class make 1 abstract method: calculateSalary(): that calculates Salary of each member in arraylist. Write another class ContractMember that extends Member
a. Provide a data member contractStart and contractEnd (LocalDateTime)
b. Provide a static constant TAXRATE and initialize it to 0.07
c. Provide getters, setters and appropriate constructors
d. Override the method calculateSalary which calculates the salary by finding the number of days between the start and end of the contract and callculating the salary for these days @ of the rate defined earlier. The method then deducts tax from this amount @ the TAXRATE and returns the net payable amount as salary.
e. Override the toString to match the output