This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Implement LinkedList operations | |
| add(), | |
| remove(), | |
| addAll(), | |
| removeAll(), | |
| removeFirst(), | |
| removeLast(). | |
| 1) Initially add 8 elements to the LinkedList and print it. | |
| 2) Remove any three elements from the LinkedList and print the updatedLinkedList. | |
| 3) Create another LinkedList , add 3 more elements to it. Print it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create an ArrayList with name ExampleArrayList. | |
| Add 5 elements of type Integer. | |
| Print all the elements of the ArrayList. | |
| Now remove all the elements from this ArrayList and print the output. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create an ArrayList with name MyArrayList. Add 5 elements of type String. | |
| Print all the elements using get() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create a package called firstpack. Create a class Cricket. Create a method | |
| msg() in the class Cricket with a printing message “I love Cricket and Badminton | |
| both.” Now create another package called secondpack. Create a class Badminton | |
| in secondpack package. Create object and call the msg() method from this | |
| package. Use “import” to make the packages accessible. [Multiple packages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create a package called pack. Create a class Chocolates. | |
| Create a method msg() in the class Chocolates with a printing message “I love chocolates and icecream.” | |
| Now create another package called mypack. Create a class IceCream in mypack package. | |
| Create object and call the msg() method from this package. | |
| Use “import” to make the packages accessible. [Multiple packages] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create a package called shapes. Create an interface Property with two | |
| methods color() and dimension(). Name this file as Property. Now implement | |
| the above interface in the same package shapes but in a different java file called | |
| Rectangle. [Package and Interface] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ ] Create a package called animals. | |
| [ ] Create an interface Animal with two methods eat() and travel(). | |
| [ ] Name this file as Animal. | |
| [ ] Now implement the above interface in the same package animals but in a different java file called WildAnimals. [Package and Interface] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 5.4 [Abstract class and abstract method]: | |
| Create MyClass as the abstract super class with an abstract method calculate(). | |
| This method does not have any body within it. Sub1, Sub2 and Sub3 are three sub classes where the abstract method is implemented as per the requirements of the objects. | |
| Sub1 calculates square root as x*x, | |
| Sub2 calculates square root using Math.sqrt(x) and | |
| Sub3 calculates cube of x. | |
| Since the same abstract method is implemented differently for different objects , they can perform different tasks. | |
| Write a program where the abstract class MyClass has one abstract method which has got various | |
| implementations in sub classes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 5.3 [Constructor Overloading] Create a class Person with three data members name, id and age. Create | |
| a constructor with two arguments for id and name and second constructor with three arguments for id , | |
| name and age. Create two objects p1 for the first constructor and p2 for the second constructor. Create | |
| a display() method to display id, name and age of the person. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Parameterized constructor] Create a class Student with two data members viz. id and name. | |
| Create a parameterized constructor with two arguments for id and name. Create a method display() to | |
| display id and name of the two students. Create two objects s1 and s2 for the same. |