Skip to main content

Mock Test: CSE310



PROGRAMMING IN JAVA (CSE310)
Time Allowed: 02:00 Hrs                                                                                                   Max. Marks: 50
           PART B
Q2 a) Write a program to create a class named find_Average which contains a static method named getAverage which accepts a two-dimensional array of size M X N and returns an array of size M containing the largest element in corresponding row of input array.                                                                                                              [10 Marks]
Example: Input:  {{1, 6, 3, 8},                                        
                                  {6, 5, 7, 2},
                                     {3, 5, 1, 5}
                                  }
Output: [8, 7, 5]
OR
b) (i) What is the difference between LocalDate and LocalDateTime class? What is the use of parse method in these classes? Write code snippet to create a LocalDate object with date 30 April 2017 using of method.                 [5 Marks]
(ii) Write a program to define a class named Employee with attributes name salary and id. Also provide a parameterized constructor to initialize all the attributes.
Create a class TestEmployee in which create at least 3 employee objects and Store in an arraylist.
Implement a method public void search(int id) which display the name and salary of the employee with given id.                                                                                                                                    [5 Marks]
Q3 a) What do you mean by Singleton design pattern? Discuss a scenario where singleton design pattern can be used? Write a program to implement that scenario.                                                                                               [10 Marks]
OR
b) (i) Differentiate between method and constructor. What do you mean by constructor chaining? Explain with suitable example.                                                                                                                                                    [5 Marks]
(ii) Write a program which prompts the user to enter a String now implement the following method
public int[] countVowels(String s)
which returns the array containing the number of vowels in String s. Where the count of a, e, i, o, u is stored in indexes 0 to 4 respectively.                                                                                                                                        [5 Marks]
Q4 a) Write a program to define an interface Person containing abstract method public VoterId getVoterID().
Create a class Employee which inherits Person and contains an inner class VoterId with attributes id and name. Implement the getVoerId method such that it reads the name and automatically assigns a unique id to each Employee Object and return the VoterId object.
Define a Main class in which create two Employee objects and display their name and VoterId.                    [10 Marks]
OR
b) (i) Define a class Test containing a method public void demo(). Define a local class MyLocal inside demo() and MyLocal must have a method public int add(int a, int b). Invoke the add method from another class TestLocal.
           [5 Marks]
(ii) Differentiate between following:
                (a) Abstract class and Interface
                (b) default method and static method in an interface
                (c) Anonymous class and Lambda Expression                                                                              [5 Marks]

Q5 a) What do you mean by Serialization? Differentiate between flush() and close() methods.
Write a program to define a class Employee having attributes name, emp_id and salary. Create 5 Employee objects and write those objects in a file named as Employees.txt.
Write a method public void getDetails(int minsalary) which displays the name, emp_id and salary of all the employees having salary less than the input minsalary.
[Hint: Use Object Input/Output Stream]                                                                                                     [10 Marks]
OR
b) (i) Write a program to define a user defined exception class named as "InvalidStringException" which prints "Length of String is ODD" when the object of this class is printed.
Create a class MyString which prompts the user to enter a string s and if the number of characters in s is odd then throw the InvalidStringException and handle it using try-catch-finally.                                                                      [5 Marks]
(ii) What do you mean by assertion? What is the significance of using assertions in java? How it is different from Exception handling?                                                                                                                                    [5 Marks]

Q6 a) Write a program to define a class Employee with attributes employee_id, name and designation and a parameterized constructor to initialize all the attributes.
Read the details of Employee from the user at run time and store 4 Employee objects in an appropriate collection such that the details of Employee can be directly fetched using the employee_id as the search key.
In a class TestCollection, prompt the user to enter the employee id and display all the details of employee.                                                                                                                                                [10 Marks]
OR
b) (i) What do you mean by Wildcard argument in generics?
Write a program to implement a method which accepts an arraylist containing duplicate values and returns a Collection having unique elements only.
    public <E extends Number>Collection removeDuplicate(ArrayList<E > al)                                        [5 Marks]

(ii) Differentiate between following:
                (a) Iterator and ListIterator
                (b) HashSet and HashMap
                (c) ArrayList and Vector                                                                                                             [5 Marks]


Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. please upload the answers sir for reference

    ReplyDelete
  3. This is very useful. we sincerely appreciate your effort.

    ReplyDelete
  4. Thanks sir , for giving us idea , that question can be framed.

    ReplyDelete
  5. thank you so much sir for your cooperation

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Thanks for sharing this valuable information to our vision.
    Java Online course

    ReplyDelete
  9. COEPD LLC - Center of Excellence for Professional Development is the most trusted online training platform to global participants. We are primarily a community of Business Analysts who have taken the initiative to facilitate professionals of IT or Non IT background with the finest quality training. Our trainings are delivered through interactive mode with illustrative scenarios, activities and case studies to help learners start a successful career. We impart knowledge keeping in view of the challenging situations individuals will face in the real time, so that they can handle their job deliverables with at most confidence.

    coepd.us/index.html

    ReplyDelete
  10. Nice blog Content.It is very informative and helpful. Please share more content. Thanks.
    JAVA Training
    JAVA Course
    JAVA Institute

    ReplyDelete
  11. BE projects in chennai is the well choice in chennai for offering final year IEEE projects for btech projects in chennai and best InPlant Traning-IPT for Engineering students. We're inside the constant lookout of higher techniques for overwhelming our customers our clients with equipment that placed them in btech projects in chennai.

    ReplyDelete
  12. It is really a great and useful piece of info. I’m glad that you shared this helpful info with us.Thank you for sharing.
    Ieee robotics projects in chennai | Cse project centers in chennai

    ReplyDelete
  13. Thanks for Sharing this Valuable Information i like this i Can Share this with My Friend Circle.
    Google Cloud Platform Training in Hyderabad

    ReplyDelete
  14. I go through your blog it's really very interesting post and useful information. I like it very much.
    Thanks for sharing.

    Vehicle Tracking System
    Fleet Management Software

    ReplyDelete

Post a Comment

Popular posts from this blog

Practice MCQs

  1. What will be the Output of the following code? class X{                  static int x = 1;                        static class Y {                              static int y = x++;                                static class Z                                                                       {                                                                                         static int z = ++y;                                                                        }                                               }                }   class MainClass{     public static void main(String[] rk)    {                             System.out.print(X.x);                                             System.out.print(X.Y.y);                             System.out.print(X.Y.Z.z);         } } A. 113 B. 123 C. 111 D. None of These Ans: A 2.  Which of the following statement is TRUE about t he following code? public class Outer  {    private i

Practice Set

1. Write a program to create a class Voter which contains attributes name, date_of_birth and voter_id and voter has a Voter_Card. Provide appropriate constructor to initialize all the attributes of the Voter but voter id must be assigned automatically only when the age of the voter is greater than or equal to 18 years. VoterCard is a nested class with attributes voter_id and Voter_name. Make sure that voter card is created only when user is a valid voter and if it is already created then must not be assigned the new voter id. 2. Write a program to define two interfaces UGC and AICTE both having a default method int getAdmission() to take the admission and an abstract method String payFee(). getAdmission() in UGC must ask the percentage in qualifying exam and if the percentage >= 60 then generate the registration number and return. getAdmission() is AICTE must ask the user to join the counseling after 5 days and display the date of counseling and return the counseling token numb

Mock Test - 1

1. Which of the following is a byte stream class? A. ObjectInputStream B. Writer C. PrintWriter D. Scanner Ans: A 2. Which exception is thrown by read() method in InputStream class? A. IOException B. InterruptedException C. FileNotFoundException D. None of These Ans: A 3. Which of the following class is subclass of FilterInputStream? A. InputStream B. ObjectOutputStream C. FileInputStream D. BufferedInputStream  Ans: D 4. Which of these class contains the print() and println() methods? A. System B. out C. PrintStream D. BUfferedOutputStream Ans: C 5. Which of these is a method to clear all the data present in output buffer without terminating the stream? A. clear() B. fflush() C. flush() D. close() Ans: C 6. Which of these classes defined in java.io and used for file-handling are abstract? (i) InputStream        (ii) PrintStream    (iii) Reader        (iv) FileInputStream A. Only i     B. i and ii    C. Only iii    D. i and iii Ans: D 7. What is the output of this program? class MyE