summary refs log tree commit diff stats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/index.typ28
1 files changed, 8 insertions, 20 deletions
diff --git a/java/index.typ b/java/index.typ
index 3cf144f..b9a4907 100644
--- a/java/index.typ
+++ b/java/index.typ
@@ -44,20 +44,17 @@
 + Write a program to create a base class named `Rectangle` and another class named `Cuboid` deriving `Rectangle` overloading the constructors and print surface area and volume of a `Cuboid` object.
 + Write a program to create a class `Employee` with instance variables `name` and `id`; a subclass of `Employee` named `Scientist` with instance variables `no_of_publication` and `experience`; and its subclass named `DScientist` with instance variable `award`; implement the `public String toString() { }` method in each class to describe about its object with the member variables and from `main()` method create an object of each class and print each object.
 + Write a program to create a class named `CircularBase` containing a method `getArea()` to calculate the base area, an interface named `_3dShape` with two methods `calArea()` and `calVolume()`, two subclasses of `CircularBase` named `Cone` and `Cylinder` implementing `_3dShape`; calculate the base area and volume of these shapes with the help of `calArea()` method.
++ Write a program to create a class containing an inner class to show that inner class can use members of outer class directly, but the outer class can use members of inner class only through its objects. Check the name of the inner class file created when it was compiled.
++ Create two interfaces, each with two methods. Inherit a new interface from the two, adding a new method. Create a class by implementing the new interface and also inheriting a concrete class. In the `main()` method, create an object of the derived class and call these methods [do all without package statement].
++ Create an Interface. Create two sub-classes implementing the interface. Show the functionalities of runtime polymorphism / dynamic method dispatch using them.
+5. Create a class with variable(s) and method(s) (all will be default accessed) under package `pOne`. Now create a class under package `pTwo`, which is subclass of firstly created class. In the method here (_i.e._ class of `pTwo`) call variable(s) and method(s) of previous class (_i.e._ class of `pOne`). If errors come, rectify them. Now from `main()` (under working directory) access members of the second class.
++ Create an interface containing three methods, in a package `pkgOne`. Implement the interface from a class under package `pkgTwo`. From `main()`, under working directory, create object of the class and call methods of interface.
++ Write a program to take an integer number from the user. If the number is less then zero then throw a custom exception. Also, catch the exception when other datatypes except integers are given. 
++ Write a program in Java to create three threads printing 1 to 100. Implement the program using both inheriting Thread class and implementing Runnable interface.
 
 #line(length: 100%)
-
 #colbreak()
 
-=== assignment(3)
-#objective[To learn about inheritance, polymorphism, and abstract classes.]
-
-+ Create a class shape with three methods to calculate area of triangle, rectangle and square with method overloading.
-+ Create an abstract class `Shape` with two abstract methods, `area()` and `disp()`. Now design three concrete classes `Rectangle`, `Circle` and `Triangle` can compute area and display its separately.
-+ Overload the constructors for classes `Area` and `Volume` of a rectangular figure and also display its area and volume. `Area` is the superclass and `Volume` is the subclass.
-+ Create a class `Employee`, having instance variables `name` and `id`. Create its subclass named `Scientist` which has instance variables `no_of_publication` and `experience`. Now create its subclass, say `DScientist` which has instance variable `award`. Put a method like: `public String toString() { }` in every class where you describe about the class and from `main()` method create object of each class and print each object.
-+ Create a class with a method `void show()` and make three subclasses of it and all subclasses have this `show()` method overridden and call those methods using their corresponding object references.
-+ Do the problem 4 using dynamic method dispatching.
 + Assume that a bank maintains two kinds of account for its customers, one called savings account and other called current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance (say Rs. 1000) and if the balance falls below this level a service charge is imposed (say Rs. 100). Create a class `Account` that stores customer name, account number and type of account. From this class derive two classes `Curr_Acct` and `Savn_Acct` respectively to make them more specific to their requirements. Include the necessary methods to achieve the following tasks:
   + Accept deposit from a customer and update the balance.
   + Display the balance.
@@ -65,17 +62,8 @@
   + Permit withdrawal and update the balance.
   + Check for minimum balance, impose penalty, if necessary, and update balance.
   Use constructors to initialise the class members.
-+ Create a class `Parent` having instance variables `id`, `name` and `address`. Create a class `ChildOne` having instance variables `id`, `name`, `address` and `marks`. Also create another class `ChildTwo` with instance variables `id`, `name`, `address`, `qualification` and `salary`. Within each class define your own method to display values of these variables. Design the program using `super` call with proper parameter and use object of each class from `main()` to display their properties.
-
-#colbreak()
-
-+ Create an interface named `Shape`. Create two subclasses of it named `Circle` and `Sphere`. Create objects of the two classes and calculate their area/surface area.
-+ Create an interface named `CircularBase` (that contains base details). Create another class `_3dShape` (Contains height, volume). Inherit two classes `Cone` and `Cylinder` from the interface and the class.
-+ Create a class which contains an inner class. Show that inner class can use member of outer class directly, but Outer class can use member of inner class only through its object. Check the name of class file, you created.
-+ Create two interfaces, each with two methods. Inherit a new interface from the two, adding a new method. Create a class by implementing the new interface and also inheriting from a concrete class. In `main()` method, create an object of derived class and call the methods [do all without package statement].
-5. Create a class with variable(s) and method(s) (all will be default accessed) under package `pOne`. Now create a class under package `pTwo`, which is subclass of firstly created class. In the method here (_i.e._ class of `pTwo`) call variable(s) and method(s) of previous class (_i.e._ class of `pOne`). If errors come, rectify them. Now from `main()` (under working directory) access members of the second class.
-+ Create an interface containing three methods, in a package `pkgOne`. Implement the interface from a class under package `pkgTwo`. From `main()`, under working directory, create object of the class and call methods of interface.
 
+#line(length: 100%)
 
 1. Take a string from keyboard and convert into character array (new one).
 2. Take a string from keyboard and a `char` array (filled up to length 5). Now append the string to that `char` array. Show the `char` array.