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

Refer to the code segment below and answer the questions in the comments labelled Question 1 – 6 For each answer; provide a brief explanation for your answer. Each answered question earns you three (3) marks.



public class Scope

{

private int x = 2;

private int x = 1;


public void start()

{


int x = 5; int x = 2;

//Question 1


System.out.printf( "The value of x is %d\n", x );


int x = 2;

//Question 2


System.out.printf( "\nThe value of x is is % d\n", x ); }

// end method begin


public void middle()

{

int x = 25;


//Question 3


System.out.printf( "\nThe value of x is %d\n", x );

++x;


//Question 4


System.out.printf( "The value of x is %d\n", x );


} // end method middle


public void end()

{

//Question 5

System.out.printf(

"\nThe value of x is %d\n", x );

x *= 10;


//Question 6

System.out.printf( "The value of x is %d\n", x );


} // end method end } // end class Scope



(i) A module is required to enable lecturers to easily identify the highest and lowest performing students in their courses. As the lead programmer, write a java program to achieve this. Your program should have the following features: Each correctly implemented feature earns you 3 marks. i. The program should make use of a sentinel to control the number of grades entered. ii. Total Number of grades entered iii. The average of the grades iv. Number of students that achieved a grade of 80 and above v. Number of students that achieved a grade of 50 and below


(ii) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. Write an algorithm for the implementation of the sentinel control in Question A Sub Question I above.


(iii) For larger datasets, a linear search may be inadequate or perhaps inefficient. What other search method can be employed to return the maximum number from a set of elements in an array. Explain your answer.


(i) Write a java program that reads three (3) int variables and performs the below operations: i. Prints out their product ii. Prints out the maximum of the numbers Do not use any inbuilt Java Methods to return the maximum. Extra marks will be awarded for clarity of code and comments. [8 marks]


(ii) Algorithms perform differently on different data sets and as such we may be interested in either their Best-case, Worst-case or Average-case scenarios. Explain why the Worst-case for an insertion sort is with reverse-sorted data. [6 marks] 


(i) Identify and correct the errors in each of the following sets of code: [6 marks] i. while ( c <= 5 ) { product *= c; ++c; ii. if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" ); iii. What is wrong with the following while statement? while ( z >= 0 ) sum += z;


(ii)Explain two (2) programming situations that will require the use of overloaded methods [5 marks]


(i) Identify and correct the errors in each of the following sets of code: [6 marks] i. while ( c <= 5 ) { product *= c; ++c; ii. if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" ); iii. What is wrong with the following while statement? while ( z >= 0 ) sum += z;


(ii)Explain two (2) programming situations that will require the use of overloaded methods [5 marks]


Write a java program that reads three (3) int variables and performs the below operations: i. Prints out their product ii. Prints out the maximum of the numbers Do not use any inbuilt Java Methods to return the maximum. Extra marks will be awarded for clarity of code and comments. [8 marks]


B. Algorithms perform differently on different data sets and as such we may be interested in either their Best-case, Worst-case or Average-case scenarios. Explain why the Worst-case for an insertion sort is with reverse-sorted data. [6 marks] 


Read the PAN Number and Name of an Employee. If the PAN Number does not contain exactly 10 characters and if the Name of the Employee is empty throw an IllegalArgumentException. If the PAN Number contains any character other than digits and alphabets(Vice versa), throw a NoSuchElementException. Considering the PAN number starts with 0 to 9 position, check for 0th to 4th (including 4th position) to be alphabets, check for 5th to 8th position (including 5th &8th position) of the PAN Number to be digit, again 9th positon must be alphabet and also 4th position of the PAN Number should be the First Letter of the employee's Name. If all the cases are valid for PAN Number print the message ‘valid’ else ‘invalid’.


When developing new software, we should take into account how to create a specific "Look and Feel" per customer. What are the advantages of using Java GUI?


Implement a code for Students information using linked list Such as student name Registration no and cgpa Write client code to retain data of students who have greater than 1.3 cgpa and also delete the record of students whose less than 1.3 CGPA java code


How to Implement a Linked List class to store the following information about students:

Registration number of the student

Name of the student

CGPA of the student


LATEST TUTORIALS
APPROVED BY CLIENTS