Q1. Write a Java class named 'Course'It should have following memberscourseIdcourseNamemaxCapacityprofessorIdcreditsint[] studentIds
Function: registerStudent(int studentId)
There should be 3 ways to create Course Object (Hint : Use Constructor)courseIdcourseId, professorIdcourseId, professorId, credits
Class should provide getters/setters for all membersregisterStudent method should store all ids in studentIds array.
———————————————————————————————————————–
Q2. In the above example, add following validations to setters/constructorscourseId – should not be negative or 0courseName- should be a string with minimum length 10 and maximum 60maxCapacity – should not be less than 10 greater than 100professorId – should be a six digit integercredits – should be a single digit but greater than 0
———————————————————————————————————————–
Q3. Add a function called removeDuplicates in Course classThis function should be called if course has reached the maximum capacity andremove all duplicate student Ids and return the new ids
Ex: Input :[1,6,2,3,2,4,5,6]Output: [1,6,2,3,4,5]
public int[] removeDuplicates(int[] studentIds) {}
———————————————————————————————————————–
Q4. Implement the following method in Course class.
public int groupsOfStudents(int[] studentIds) {
}
The above method takes an array of studentIds as an argument. Find number of pairs of studentsIds whose sum is evenExample:Input : [1,2,3,4,5,6]Output : 6Explanation: (1 + 3), (1 + 5), (3 + 5), (2 + 4), (2 + 6), (4 + 6)
———————————————————————————————————————–
Q5.The count-and-say sequence is a sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 111221
1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then one 1" or 1211.Given an integer n where 1 = n = 30, generate the nth term of the count-and-say sequence.Note: Each term of the sequence of integers will be represented as a string.
Example 1:Input: 1Output: "1"
Example 2:Input: 4Output: "1211"public String countAndSay(int n) {
}
———————————————————————————————————————–
Q6. Given an input string , reverse the string word by word.Example:Input : “the sky is blue”Output : “blue is sky the”Assumptions:A word is defined as a sequence of non-space characters.The input string does not contain leading or trailing spaces.The words are always separated by a single space.
———————————————————————————————————————–
Q7.Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]
Example 2:Input:[ [1, 2, 3, 4], [5, 6, 7, 8], [9,10,11,12]]Output: [1,2,3,4,8,12,11,10,9,5,6,7]
public int[] spiralOrder(int[][] matrix) {}
———————————————————————————————————————–
Q8.The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like thisP A H NA P L S I I GY I RAnd then read line by line: "PAHNAPLSIIGYIR"Write the code that will take a string and make this conversion given a number of rows:String convert(string s, int numRows);Example 1:Input: s = "PAYPALISHIRING", numRows = 3Output: "PAHNAPLSIIGYIR"
Example 2:Input: s = "PAYPALISHIRING", numRows = 4Output: "PINALSIGYAHRPI"Explanation:
P I NA L S I GY A H RP I
———————————————————————————————————————–
Q9. Explain Encapsulation with an example. (Write at least 30-40 words).
———————————————————————————————————————–
Q10. What is the difference between Encapsulation and Abstraction

 

Doing a similar assignment? Save your time and hire our Genuine Essay Writers to do your task. Get 15% Discount on your 1st order. Use code: FREE15