Skip to main content

Practice Set: Unit-4

                                                       
                                                        Practice Set: Unit 4

1. What are the uses of super keyword in Java? Explain with a suitable example.

2. What are the various uses of final keyword in java? An abstract method can not be declared final. Why?

3. Differentiate between Abstract class and Interface. What do you mean by Functional interface and Lambda Expression?          

4. Define Anonymous class. Why we use anonymous class in Java?  

5. Differentiate between static nested class and inner class in java.

6. Write a program to define a class named Demo which contains a local class named MyLocal inside its constructor. Define a method sayHello (String XXX) to display Hello XXX (e.g Hello Ravi if name is Ravi).

Define a class named TestLocal which reads the name from the user and then invoke the sayHello method of MyLocal class.  

7. Complete the following program as per comments.
abstract class A
  {
abstract void x();
abstract void y();
  }
class UseAbstract
  {
/*Use anonymous class to define and call methods of abstract class A*/
  }
      
8. Create a functional interface Predicate with an abstract method test with following signature:
            boolean test(String t);
Write a test program to check a string contains character 'c' or not by using above test method with the help of lambda expression.

9. Write a program to define an interface Testing which contains an abstract method
boolean checkString(String str)

Create a class Input which must contain a method String getInput(Testing obj) which prompts the user to enter a String and the String must be checked using the checkString such that it returns TRUE only when the String contains all the vowels. If input is correct then display “String Accepted” otherwise ask to re-enter the String.

10. Write a program to create a class Employee with appropriate fields for employee name, employee id and Vehicle.
Vehicle is a nested class with attributes vehicle number and owner name. An employee may or may not have a vehicle.
Create at least 3 employee objects using appropriate constructor and store the employee objects in a collection.
Implement a method getVehicleDetails(String Vehicle_number) to display the name and id of the employee who own that vehicle.

Comments

  1. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
    Best AWS Training in Chennai | Amazon Web Services Training in Chennai



    ReplyDelete
  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    ReplyDelete
  3. nice topic
    http://www.greenstechnologys.com/java-training-course-content.html

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

    ReplyDelete
  5. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Data Science training in Chennai | Data science training in bangalore

    Data science training in pune | Data science online training

    Data Science Interview questions and answers

    ReplyDelete
  6. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
    java developers in hyderabad

    ReplyDelete
  7. Now this is very easy to withdraw bitcoin from blockchain wallet to paypal account just in seconds. This website is providing you many features and facilities. This is best chance to register for free and get surprises from our company on this new year.

    ReplyDelete
  8. Now this is very easy to withdraw bitcoin from blockchain wallet to paypal account just in seconds. This website is providing you many features and facilities. This is best chance to register for free and get surprises from our company on this new year.

    ReplyDelete
  9. Hello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
    Android Training in Chennai
    Selenium Training in Chennai
    Devops Training in Chennai

    ReplyDelete
  10. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.

    Microsoft Azure online training
    Selenium online training
    Java online training
    Java Script online training
    Share Point online training

    ReplyDelete
  11. Visit : https://mlait.tech for more updates on different programming languages.

    ReplyDelete
  12. Thanks for sharing this informative blog java training in chennai

    ReplyDelete
  13. click here for more info.
    ....................................................................

    ReplyDelete
  14. I should assert barely that its astounding! The blog is informational also always fabricate amazing entitys. live crypto ticker

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

    ReplyDelete
  16. I have read your article, it is very informative and helpful for me. I admire valuable information you offer this articles. Thanks for posting it. Flutter App Development Services

    ReplyDelete
  17. This is the first time I am visiting your website. I would like to tell you that I am genuinely engaged by reading your blogs. Keep up the good work! React Native App Development Services

    ReplyDelete
  18. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging ! Flutter App Development Services

    ReplyDelete
  19. Hey thanks for this wonderful information simply explanation is best keep
    posting im waiting for more post !!!
    SEO SERVICE SPECIALIST!

    ReplyDelete
  20. Nice Information and keep posting this type of Information.You can also visit us in need of any assistance with Ecucational information.Big Data Course

    ReplyDelete
  21. Appreciate you sharing, great article.Much thanks again. Really Cool.. net online training
    dot net online training hydarabad

    ReplyDelete
  22. They're produced by the very best degree developers who will be distinguished for your polo dress creation. You'll find Ron Lauren inside an exclusive array which includes particular classes for men, women.
    business analytics training in hyderabad

    ReplyDelete
  23. BetMGM agrees to revamp sports betting - KTNV
    BetMGM has agreed 군포 출장안마 to rebrand its online sportsbook, with the move 제천 출장마사지 being 군산 출장마사지 made to 의왕 출장샵 rebrand its 창원 출장샵 sportsbook.

    ReplyDelete
  24. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it. data science training in kanpur

    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