Hi, Please workout the following java assignment.
1. Create a class Box and represent its data members as width, height and depth assign the values to them by using constructor to the class Box & assign its values as 10, 20, 15 respectively. Now calculate the volume of the box by creating the method as volume( ). create an object ‘mybox’ to that class Box and invoke the method volume( ) by object and display the output on the console device.
2.Let us Consider a multi dimension matrix as A of which it contains elements in 3 rows & columns, similarly consider another matrix with same dimension B . a. perform the addition of 2 matrices and store the result in another matrix named c. b. Perform the matrix multiplication of the 2 matrices and should store the result in c.
3.Create a class ‘Car’ and using its constructor it should be instantiate it’s variables like speed, brand and model . make the usage of ‘this’ keyword to instantiate class variables, so that both the class instance variables and constructor parameters should be same. from the main( ) method’s constructor you should pass 90, 786, and 2018 as parameters to the constructor.
4.Make the usage of concept ‘Method Overloading’ to achieve the object oriented principle of ‘polymorphism’. Create a method test( ) and apply method overloading to it. overload test( ) for no parameters, for single int parameter 10, for 2 int parameters 10,20 and for single double parameter 150.65. From main ( ) pass the values as parameters to their corresponding methods.
5.By using parameter passing mechanisms call by value and call by reference show the output after changing the values of formal parameters. consider the values to be passed a=10, b=20. What happened after applying the concept of call by value and call by reference. Take different classes for both concepts.
6.Using the concept of ‘Recursion’ which means a function calling it self, create a factorial program in which the function should call it self. Calculate the factorial for the numbers 7 & 9. (Hint for logic 3!=3*2*1*1=6). For suppose if you give input as 1 then it should return 1 as output. (constraint to consider: 1!=1).
7.Demonstrate the access of specifiers like default, public & private for 3 integer variables namely a,b &c respectively. From the main( ) create an object and access those data members of the class a,b &c. Note the corresponding output for accessing the data members.
8.Using ‘static’ keyword declare a data members p=3 and q, define a method meth( ) also define the static block which should perform the q=p+4 functionality, which is going to be executed once before the actual class get loads. Observe the output in different cases. pass a value to meth(23) from main( ).
9.Use ‘string’ class and create 3 objects as ob1=”raziya”, ob2=”binish” & ob3 should assign the reference of ob1. Now calculate the length of first string “raziya” by using length( ) and extract the third character of the second string “binish” by using charAt(int index) functionality. Also check whether all the 3 strings equal or not.
10.By using the concept of command line arguments, you should pass the statement as input to the main( ) from command line “binish learning java language”. Also make use of args.length property to display the the output at it’s corresponding indeces.