Skip to main content

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 number.

Create a class University which inherits both UGC and AICTE and overrides the getAdmission() method only such that it will ask the percentage and if direct admission through UGC is possible then proceed otherwise proceed through AICTE.

University must have attribute fee_due and it should be assigned the due amount accordingly.(E.g fee through UGC is 25000 & fee through AICTE is 34000)

Create a class LPU which inherits University and overrides all the methods. Ask the user to deposit the fee and display the fee due. After depositing the fee display the remaining due fee and return the receipt number.

3. Write a program to create a class named IPL _Team with appropriate attributes for team name, wicketkeeper, allrounder and captain. Provide a constructor to initialize all the attributes.
Player is a private nested class with attributes player name, price and a suitable constructor to initialize the attributes.

In main class, create at least 3 teams each having a captain and a wicket-keeper and at least one all-rounder and store the teams in an arraylist.
Implement a method which displays the name of the team and details of all the players of that
team whose captain is having highest price.

4. Create a class Laptop with attributes model_number, price and RAM.
In main class prompt the user to filter on the basis of model, price or RAM and if user selects Price then display all the laptops in descending order of the price and if user selects RAM then display all the laptops in ascending order of their RAM and if user select model then ask to enter the keyword for model and display all the laptops which contain that keyword in model_number.

Comments

  1. Answer for the first question : Correct the code if any necessary.


    class Voter
    {
    String name;
    String dob;
    int id;
    Integer age;
    //boolean card;
    Voter(String names , String dobs , int ids , Integer ages)
    {
    name = names;
    dob = dobs;
    age = ages;
    if(age > = 18)
    {
    id= ids;
    }
    // card = cards;
    }
    class Voter_Card
    {
    boolean status;
    String votername;
    int voterid;
    Voter_Card(String voternames , int votersid , boolean statuss)
    {
    votername = voternames ;
    voterid = votersid ;
    status = statuss;
    }
    }
    public void display()
    {
    System.out.println(votername+ "\t" + voterid +"\t"+dob+"\t"+age+"\t"+status+"\t");
    }
    }
    class main
    {
    public static void main(String...rtk)
    {
    Treeset ts = new Treeset();
    Voter obj = new Voter("Raj" , "04/04/1998" , 11605461 , 18);
    Voter obj1 = new Voter("Srinjay" , "05/06/1999" , 11605641 , 17);
    Voter obj2 = new Voter("Dam" , "06/05/1997" , 11605879 , 19);
    ts.add(obj) ; ts. add(obj1) ; ts.add(obj2);
    Iterator i = new iterator();
    int a=2;
    while(i.hasNext())
    {
    Voter e = e.next();
    if(e.age >= 18)
    {
    namess = e.name;
    idss = e.id;
    Voter.Voter_Card obj4 = new Voter.Voter_Card(namess , idss, true);
    }
    e.display();
    }
    }
    }

    ReplyDelete
  2. Can anyone please tell me how can i make the CODE FOR THE 3rd QUESTION CORRECT?::


    class IPL_Team
    {
    String name , wck , alrnd , cpt;
    IPL_Team(String names , String wicky , String allround , String captain)
    {
    name = names;
    wck = wicky;
    alrnd = allround;
    cpt = captain;
    }
    private Player
    {
    String pname ;
    Integer price;
    Player(String playername , Integer pricee)
    {
    pname = playername;
    price = pricee;
    }
    }
    Player obj4 = new Player("Vicky",12000);
    Player obj5 = new Player("Vikas",15000);
    Player obj6 = new Player("Varun",9000);
    public void display()
    {
    System.out.println(name + "\t" + wck + "\t" + alrnd + "\t" +cpt+"\t");
    }
    }
    class main
    {
    public static void main(String...rtk)
    {
    TreeSet ts =new TreeSet ((x,y)->y.price.compareTo(x.price)); //specifically calling the compareTo function to perform sorting mechanism.
    IPL_Team obj1 = new IPL_Team("Draco" , "Dhoni" , "Umesh" , "Vicky");
    IPL_Team obj2 = new IPL_Team("Dignitas" , "Mahi" , "Rahul" , "Vikas");
    IPL_Team obj3 = new IPL_Team("Faze" , "Konak" , "Satir" , "Varun");
    ts.add(obj1) ; ts.add(obj2) ; ts.add(obj3);

    Iterator i = ts . iterator();
    while(i.hasNext())
    {
    IPL_Team t = i.next();
    t . display();
    break;
    }
    }
    }

    ReplyDelete
  3. Anyone pls write the program from 4th question

    ReplyDelete
    Replies
    1. have you done this 4th question or you still want answer for it? i can do it for you id u want

      Delete

  4. Thank you for your post. This is excellent information. It is amazing, I wonderful to visit your Blog.
    iphone job Oriented course
    Mobile App Training Institutes

    ReplyDelete
  5. Hello Everybody,
    My name is Mrs Sharon Sim. I live in Singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) Thank you.

    ReplyDelete
  6. your blog is nice.thank you
    visit
    web programming tutorial
    welookups.com

    ReplyDelete
  7. I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
    full stack developer training in chennai

    ReplyDelete
  8. It is very good and useful for students and developer . Learned a lot of new things from your post. Thank you so much.
    Google Cloud Platform Training in Hyderabad

    ReplyDelete

  9. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    Best AWS Training in Chennai | Amazon Web Services Training in Chennai

    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR


    AWS Training in Chennai |Best Amazon Web Services Training in Chennai


    AWS Training in Velachery | Best AWS Course in Velachery,Chennai

    ReplyDelete
  10. The blog was absolutely fantastic, Lot of information is helpful in some or the other way. Keep updating the blog, looking forward for more content…. Great job, keep it up
    Tutor Jobs in Delhi | Home Tutors in Delhi

    ReplyDelete
  11. Would you like to get beginning with these tools for free or talk to anyone about search engine marketing? toprankingseo.net's marketing tools have everything you need is clear. visit our site and see more monthly and weekly packages for SEO And (SEM) search engine marketing . I sure that every person like this my company tool.

    ReplyDelete
  12. Please give me the answer of second question

    ReplyDelete
    Replies
    1. Hello bro, if you got the answer of second one then please send me bro...
      on this email "adityarajarya111@gmail.com...

      Delete

  13. Its a wonderful post and very helpful, thanks for all this information.
    MCSE Training in Noida

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

    ReplyDelete
  15. Good Post! Thank you so much for sharing the post, it was so good to read and useful to improve
    Java Training in Electronic City

    ReplyDelete
  16. can anyone tall code for 2nd question..???

    ReplyDelete
  17. guys please help me , i need code for 2nd question...

    ReplyDelete
  18. does any one have 2nd question code

    ReplyDelete
  19. Answer 1:
    /*2. 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.
    */
    import java.util.*;
    class Voter{
    String name;
    String dob;
    int id;
    Integer age;
    Voter.Voter_Card votercard;
    //boolean card;
    Voter(String names , String dobs , int ids , Integer ages){
    name = names;
    dob = dobs;
    age = ages;
    if(age >= 18)
    id= ids;
    // card = cards;
    }
    class Voter_Card{
    boolean status;
    String votername;
    int voterid;
    Voter_Card(String voternames , int votersid , boolean statuss){
    votername = voternames ;
    voterid = votersid ;
    status = statuss;
    }
    public void display(){
    System.out.println(name + "\t" + id +"\t"+dob+"\t"+age+"\t"+status+"\t");
    }
    }
    public void display(){
    if (votercard == null)
    System.out.println(name + "\t" + dob + "\t"+age+"\t"+"\tvoter card not assigned!");
    else
    votercard.display();
    }
    }
    class main{
    public static void main(String...rtk){
    List voters = new ArrayList();
    voters.add(new Voter("Aman" , "14/09/1998" , 11703461 , 17));
    voters.add(new Voter("Shanu" , "25/07/1997" , 11705941 , 18));
    voters.add(new Voter("Sumit" , "17/04/1999" , 11804569 , 19));
    int a=2;
    for (int i=0; i= 18)
    {
    String namess = voters.get(i).name;
    int idss = voters.get(i).id;
    voters.get(i).votercard = voters.get(i).new Voter_Card(namess , idss, true);
    }
    voters.get(i).display();
    }
    }
    }

    ReplyDelete
  20. pls upload the answer for second question

    ReplyDelete
  21. Thanks for sharing this practice set of Java, as a java developer I suggest every company looking to Hire Java Developers then you must aware about the basics of Java Development.

    ReplyDelete
  22. plzz anyone help me in question 10 plzz give me code plz

    ReplyDelete
  23. We are Hire Java DevelopersHire Programmers will provide dedicated freelance java developers/programmers to build a effective team to client businesses.

    ReplyDelete
  24. AI is the future trend of web space development. It is justified as a lot of progress and advancements have been made in the field of Artificial Intelligence. ... One of the latest AI implementation is the grid, which allows web development a simple process, and initiates content-based development.keep up!!

    Android Training in Chennai

    Android Online Training in Chennai

    Android Training in Bangalore

    Android Training in Hyderabad

    Android Training in Coimbatore

    Android Training

    Android Online Training


    ReplyDelete
  25. We are Hire Programmers offers freelance programmers & Freelance IT Projects at a fraction of cost on the World's Largest Outsourcing Marketplace

    ReplyDelete
  26. Hello.
    Are you looking for an amazing logo design for your business with 50% off I expect You will be impressed with us.Logo Designers

    ReplyDelete

  27. This is really too useful and have more ideas and keep sharing many techniques. Eagerly waiting for your new blog keep doing more.
    DevOps Course in Chennai
    DevOps Online Course
    DevOps Course in Coimbatore

    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

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