Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Question 3: (Inheritance)

Create an abstract class called Employee that has an abstract method call computePay() which

computes the total pay per employee using the rate per hour = $50. The method should accept

the number of hours the employee has worked. Create a child class called employeeChild and

provide the implementation. In the main method invoke that method and get the number of hours

worked from the user and pass it to the called method.



Question 2 (Polymorphism)

Mathematically, the area of a rectangle is computed as length * width, the area of a circle is

computed as pi*radius*radius. Given that pi = 3.14, write a Java program with an overloaded

method called getArea() that can compute for the area of a circle or rectangle depending on the

parameters supplied. Illustrate how you will invoke the method in the main method for the two

scenarios.



Question 1: (Inheritance)

Consider a scenario where you have been given three classes, namely Vehicle, Bus, and

School_Bus. The School_Bus class is supposed to inherit all characteristics of both the Vehicle

and the Bus class. Explain and illustrate how you are going to achieve this considering you are using Java programming language.



Write a complete Java program illustrating the difference between instance and static members of class. Indicate with comments where each is used and explain the significance of making the instance or static. (6 marks)



Making use of object orientation write a program that stores and evaluates the total cost for items bought from a supermarket. The cashier should enter the following: - Product code, Price and Quantity. The total price should be evaluated as follows: -



Total cost = Price * Quantity



If the total cost per item is more than 20,000 there is a discount of 14% on that item and a discount of 10% on an item whose total cost is between 10,000 and 20,000. No discount is given on items whose total cost is less than 10,000



how to do a STUDENT INFORMATION using GUI in NETBEANS?


1.      Write a program using Java to move the last element of a LL to the beginning of the list.

 

2.      Write a program using Java to find the number of common elements of two linked lists.

e.g. 1à3à5à7ànull

       2à3à7à9à11ànull

Output: 2

 

3.      Write a program using Java to reverse the elements of a linked list

 

4.      Write a program using Java to find the middle node of a linked list (ensure that the number of nodes of the LL is an odd number).

 

5.      Write a program to count the number of times a given integer appears in a LL.

 

6.      Preparation for theory-based questions which can be asked during interview.

 

6.1  Linked List vs 1-d Array

6.2  Comparison of Singly Linked List, doubly linked list and circular Linked list. Advantages and disadvantages of each.



1.      Write a Java program to rearrange a given array of unique elements such that every second element of the array is greater than its left and right elements.  

 

Example:

Input :

nums= { 1, 2, 4, 9, 5, 3, 8, 7, 10, 12, 14 }

Output:

Array with every second element is greater than its left and right elements:

[1, 4, 2, 9, 3, 8, 5, 10, 7, 14, 12]

 

2.      Write a Java program to form the largest number from a given list of non-negative integers.  

 

Example:

Input :

nums = {1, 2, 3, 0, 4, 6}

Output:

Largest number using the given array numbers: 643210

 

3.      Write a Java program to shuffle a given array of integers.

 


 

4.      Write a Java program to find maximum product of two integers in a given array of integers.  

 

Example:

Input :

nums = { 2, 3, 5, 7, -7, 5, 8, -5 }

Output:

Pair is (7, 8), Maximum Product: 56



1.      Write a Java program to find the maximum and minimum value of a 1-d array.

 

2.      Write a Java program without using a second array to reverse elements of each row of a 2-d array of integer values.

e.g.      1    2   3    4                                      4    3    2  1

               5    6   7    8          è                    8    7    6  5

             9   10  11 12                                    12  11  10  9

 

3.      Write a java program to print the Pascal’s Triangle using a 2-d array.

 

4.      Write a Java program to convert an array to an ArrayList, and an ArrayList to an array.

 

5.      Write a Java program to arrange the elements of a given array of integers where all negative integers appear before all the positive integers.



Implement your own version of the priority queue data structure using java with OOPs principles mentioned functionalities: enqueue, Dequeue (highest priority), peek(highest priority), contains, size, center, sort reverse, iterator, traverse/print.

Use of similar data structures already present in the language/framework is not allowed.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS