Skip to content

Instantly share code, notes, and snippets.

View Liyansu's full-sized avatar
🏠
Working from home

Liyansu

🏠
Working from home
View GitHub Profile
@Liyansu
Liyansu / 7.3 Que.txt
Created June 5, 2021 17:59
7.3 Implement LinkedList operations
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.
@Liyansu
Liyansu / 7.2 Que.txt
Created June 5, 2021 17:55
7.2 Create an ArrayList with name
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.
@Liyansu
Liyansu / 7.1 Que.txt
Last active June 5, 2021 17:43
7.1 Create an ArrayList with name MyArrayList.
Create an ArrayList with name MyArrayList. Add 5 elements of type String.
Print all the elements using get()
@Liyansu
Liyansu / 6.4 Que.txt
Last active June 5, 2021 17:28
6.4 Create a package called firstpack
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
@Liyansu
Liyansu / 6.3 Que.txt
Last active June 5, 2021 17:28
6.3 Create a package called pack
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]
@Liyansu
Liyansu / 6.2 Que.txt
Last active June 5, 2021 17:29
6.2 Create a package called shapes.
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]
@Liyansu
Liyansu / 6.1 Que.txt
Created June 5, 2021 17:06
6.1. Create a package called animals.
[ ] 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]
@Liyansu
Liyansu / 5.4 Abstract class and abstract method.txt
Created June 5, 2021 16:57
5.4 Abstract class and abstract method.txt
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.
@Liyansu
Liyansu / 5.3 Que.txt
Created June 5, 2021 16:54
5.3 [Constructor Overloading].txt
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.
@Liyansu
Liyansu / 5.2 Parameterized constructor .txt
Created June 5, 2021 16:50
5.2 [Parameterized constructor]
[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.