Docsity

Java Programming: Inheritance, Encapsulation, Abstraction, Polymorphism, and Multithreadin, Assignments of Statistics

Toggle sidebar
bg1
Q1)
a)to solve this we first initialize an array of adequate length then in a loop we pass the inputs
and store the result in the array. to display we run a loop from the first letter to the seventh
letter and print them.rest is not printed.
b)In order to use the functionalities of other parts of application we basically create class of each
mode and in order to use the functionality we just access the class by making a new Instance of
the class.
c)in order to show a module we create insatance of that class module and to hide all other
module we use the dispose() function provided to us by java.
Q2
a)In order to categrize we can distribute items into Different material they are made of e.g
steel,wood etc then they are classified itno bedswardrobes,sofas,TV units,Tables,dressers,stools
and poufs classes.
b)To classify according to room we need to seprate out items such as dining tables from side
tables as they into different rooms.but we can create classes for each room and then inherit
each class with tables sofas etc as needed.
c)in part a we use single inheritance as one member only extends to one class.in part b we use
multi level inheritance as dining table inherit tables and dining hall.
Q3)
a)Calling a method that present with same signature in different class, called by a child
class object having parent class reference type is called Overriding.
b)Calling a method present only in child class, called by a child class object having
parent class reference type is called Typecasting
c)Calling a method present in with different signature in a class, called by object having
same reference and object types is called overloading.
Q4)
According to given scenerio Inheritace , Encapsulation , Abstraction can be used
Inheritace will come in handy since tax calculation and promotion discount procedure is
same for all branches.
Encapsulation can be used for smooth working of software to avoid external interference.
Abstraction can be used for limiting the user access to application and giving him only
the funcationality he wants.
pf2

Partial preview of the text

Download Java Programming: Inheritance, Encapsulation, Abstraction, Polymorphism, and Multithreadin and more Assignments Statistics in PDF only on Docsity!

Q1) a)to solve this we first initialize an array of adequate length then in a loop we pass the inputs and store the result in the array. to display we run a loop from the first letter to the seventh letter and print them.rest is not printed. b)In order to use the functionalities of other parts of application we basically create class of each mode and in order to use the functionality we just access the class by making a new Instance of the class. c)in order to show a module we create insatance of that class module and to hide all other module we use the dispose() function provided to us by java. Q a)In order to categrize we can distribute items into Different material they are made of e.g steel,wood etc then they are classified itno bedswardrobes,sofas,TV units,Tables,dressers,stools and poufs classes. b)To classify according to room we need to seprate out items such as dining tables from side tables as they into different rooms.but we can create classes for each room and then inherit each class with tables sofas etc as needed. c)in part a we use single inheritance as one member only extends to one class.in part b we use multi level inheritance as dining table inherit tables and dining hall. Q3) a)Calling a method that present with same signature in different class, called by a child class object having parent class reference type is called Overriding. b)Calling a method present only in child class, called by a child class object having parent class reference type is called Typecasting c)Calling a method present in with different signature in a class, called by object having same reference and object types is called overloading. Q4) According to given scenerio Inheritace , Encapsulation , Abstraction can be used Inheritace will come in handy since tax calculation and promotion discount procedure is same for all branches. Encapsulation can be used for smooth working of software to avoid external interference. Abstraction can be used for limiting the user access to application and giving him only the funcationality he wants.

Q6)

a)In the given scenerio cooking process is multithreaded since they can be doing multiole tasks while cooking and the shared basked part is single threaded for each item in basket. b)Inter thread communication is bad in abouve scenerio since cooking is multithreaded but shared basket is single threaded opration ,so if basket is in use other participants will have to wait for the operation to finish. c)Deadlock can occur in the scenerio when a participant forgots or decides to not put an item in the basket and that item is needed by another participant. Q7) abstraction, encapsulation, inheritance can be used in the device. Abstraction can be used for limiting the user access to application and giving him only the funcationality he wants. Encapsulation can be used for smooth working of device to avoid external interference and hide internal funcationality. Inheritace is used to get the funcationality of other devices. Q10) Statement 1 is incorrect since gernal employee doesnot have that method. statement 2 is correct. statement is incorrrect since manager have to assign task first and also super keyword is not used.