Spring 2020: Programming in Java Lab
- Instructions
- Please be on time to avoid the attendance penalty.
- Turn off(shutdown) your assigned computer after finishing your work (or before you leave the lab).
- Please arrange the chair in proper place while leaving the lab.
- Please put your phone in silent mode.
Contents
- 1 Lab 1: Getting Started ( week of 8th January 2020 )
- 2 Lab 2: ( week of 15th January 2020 )
- 3 Lab 3: ( week of 22nd January 2020 )
- 4 Lab 4: ( week of 29th January 2020 )
- 5 Lab 5: ( week of 05th February 2020 )
- 6 Lab 6: ( week of 12th February 2020 )
- 7 Lab 7: ( week of 19th February 2020 )
- 8 Lab 8: ( 18th February 2020 )
Lab 1: Getting Started ( week of 8th January 2020 )
- Brief introduction to Java Basic Building Blocks Download
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | WAP to find the sum of any number of integers entered as command line argument | Lab Exercise No. 1 | |
2 | WAP to find the factorial of a given number | Lab Exercise No. 2 | |
3 | WAP to check whether the given number is prime or not | Lab Exercise No. 6 | |
4 | WAP to print the following pattern using nested for loop:* |
Practice Set No. L1 |
Lab 2: ( week of 15th January 2020 )
- Reading input from keyboard, Arrays Download
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | WAP to read data of various types from user(keyboard) | Practice Set No. L2 | |
2 | Rewrite the Lab Exercise No. 3, by taking the number as input from the keyboard | Lab Exercise No. 6 | |
3 | WAP to learn use of single dimensional array by defining the array dynamically | Lab Exercise No. 3 | |
4 | WAP to Search an element in the array(Linear Search) | Practice Set No. L2(2) | |
5 | WAP to learn use of Two dimensional array by defining the array dynamically | Lab Exercise No. 4 |
Lab 3: ( week of 22nd January 2020 )
- String Manipulation Download
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | WAP to convert a decimal number to a binary number | Lab Exercise No. 5 | Solution |
2 | WAP to convert a decimal number to a octal number | Practice Set No. L3 | |
3 | WAP to find the sum of any number of integers interactively, i.e., entering every number from the keyboard, where as the total number of integers is given as a command line argument. | Lab Exercise No. 7 | |
4* | WAP that show working of different functions of String and StringBuffer class like setCharAt(), setLength(), append(), insert(), concat(), and equals() | Lab Exercise No. 8 | Concepts of String Handling is required |
Lab 4: ( week of 29th January 2020 )
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | Create a Box class consisting of three instance variables: width, height, and depth. Create another class named BoxDemo that:
There are no methods in this class. |
Practice Set No. L4 | |
2 | Implement Q. NO. 1 using methods. Apply the concepts like methods taking parameter, methods returning values, etc. | Practice Set No. L4(2) | |
3 | Write a program to create a “distance” class with methods where distance is computed in terms of feet and inches, how to create objects of a class and to see the use of this pointer. | Lab Exercise No. 9 |
Lab 5: ( week of 05th February 2020 )
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | Create a Box class consisting of three instance variables: width, height, and depth. Create another class named BoxDemo that:
Finally computer the volume of all three objects. |
Practice Set No. L5 | |
2* | Modify the "distance" class by creating constructor for assigning values (feet and inches) to the distance object. Create another object and assign second object as reference variable to another object reference variable. Further create a third object which is a clone of the first object. | Lab Exercise No. 10 | |
3 | Write a program to show that during method overloading, if no matching argument is found, then java will apply automatic type conversions(from lower to higher data type). | Lab Exercise No. 11 |
Lab 6: ( week of 12th February 2020 )
- Read Access Modifiers from Java T Point
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | Implement a Stack class with two data items(array stk and tos) and three methods(Stack() Constructor to initialize tos, Push(), and Pop() ) | Practice Set No. L6 | |
2 | Complete the remaining section of Q. NO. 2 of Lab 5 (using copy constructor) | Lab Exercise No. 10 | |
3* | Write a program to show the difference between public and private access specifiers. The program should also show that primitive data types are passed by value and objects are passed by reference and to learn use of final keyword. | Lab Exercise No. 12 | Read final keyword examples from [1] |
Lab 7: ( week of 19th February 2020 )
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | Write a program to demonstrate the concept of static keyword for:
|
Practice Set No. L7 | Read about static keyword in detail from [2] |
2 | Write a program to show the use of static functions and to pass variable length arguments in a function. | Lab Exercise No. 13 | Read about varargs from [3] |
3 | Write a program to demonstrate the concept of boxing and unboxing. | Lab Exercise No. 14 | Read about Autoboxing and Unboxing from [4] |
Lab 8: ( 18th February 2020 )
- Read L12 slide from Java Course Page
Q. NO. | Program | Lab Exercise No. | Remarks |
---|---|---|---|
1 | Create a multi-file program where in one file a string message is taken as input from the user and the function to display the message on the screen is given in another file (make use of Scanner package in this program). | Lab Exercise No. 15 | Read about Packages in detail from [5] |
2 | Write a program to create a multilevel package and also creates a reusable class to generate Fibonacci series, where the function to generate Fibonacii series is given in a different file belonging to the same package. | Lab Exercise No. 16 | |
3 | Write a program that creates illustrates different levels of protection in classes/subclasses belonging to same package or different packages. | Lab Exercise No. 17 |