Skip to content

Devansh2000Shaw/Web-Technology-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lab 4

Topics

  • Writing, compiling and executing a simple Java program
  • Giving input to the program in Java
  • Use of control statements in Java
  • Use of iteration statement in Java

Q1). Program to print your name, roll no, section and branch in separate lines.
Q2). Program to print the corresponding grade for the given mark using if..else statement in Java.
Q3). Program to print the corresponding week day for the given day no. of the current month using switch..case statement in Java
Q4). Program to check a user entered number is palindrome or not.
Q5). Write a program in Java to take first name and last name from user and print both in one line as last name followed by first name.

Lab 5

Topics

  • Array in Java
  • Command line arguments in Java
  • static and final modifier in Java

Q1). Find the largest among 3 user entered nos. at the command prompt using Java
Q2). Accept 10 numbers from command line and check how many of them are even and how many odd.
Q3). Program to sort the user entered list of numbers of any size.
Q4). Program to find no. of objects created out of a class using 'static' modifier.
Q5). Find the no. of occurrence of each element in an user entered list of nos.
Q6). Find sum of each diagonal (left & right) elements separately of a user entered 3 X 3 matrixes in Java.

Lab 6

Topics

  • class and objects in Java
  • method overloading in Java
  • constructor overloading in Java

Q1). Write a class file – box with three data members(length, width, height) and a method volume() . Also implement the application class Demo where an object of the box class is created with user entered dimensions and volume is printed.
Q2). Write a program to overload subtract method with various parameters in a class in Java
Q3). Write a program which will overload the area () method and display the area of a circle, triangle and square as per user choice and user entered dimensions.
Q4). Write a program in Java to define a class Rectangle having data member: length and breadth; to calculate the area and perimeter of the rectangle. Use member functions to read, calculate and display.
Q5). Write a program in java to input and display the details of n number of students having roll, name and cgpa as data members. Also display the name of the student having lowest cgpa.
Q6). Write a program to calculate area according to user input, whether it is circle, square or triangle (Menu Driven).
Q7). Write a program in Java to define a class Number with appropriate data members and member functions to input n number of integers and swap the biggest and smallest elements. Use member functions read(), swap() and display().

Lab 7

Topics

  • Single level inheritance in Java
  • Multi-level inheritance in Java
  • Method Overriding
  • Dynamic Method Dispatch

Q1).A plastic manufacturer sells plastic in different shapes like 2D sheet and 3D box. The cost of sheet is Rs 40/ per square ft. and the cost of box is Rs 60/ per cubic ft. Implement it in Java to calculate the cost of plastic as per the dimensions given by the user where 3D inherits from 2D.
Q2). Illustrate the execution of constructors in multi-level inheritance with three Java classes – plate(length, width), box(length, width, height), wood box(length, width, height, thick)
Q3). Program on Dynamic Method Dispatch.
Q4). Write a program in java to define a class Shape which has data member „area‟ and a member function showArea(). Derive two classes Circle and Rectangle from Shape class. Add appropriate data members and member functions to calculate and display the area of Circle and Rectangle.
Q5). Write a program to create an Account class containing acc_no, balance as data members and disp() to display the details. Inherit it in Person class with all mentioned data members and functions. Person class also has name and aadhar_no as extra data members of its own. Override disp() function. Create 5 persons‟ details.
Q6). Write a program in java using inheritance to show how to call the base class parameterized constructors from the derived class using super.

Lab 8

Topics

  • Abstract classes in Java
  • Interface in Java

Q1). Illustrate the usage of abstract class with following Java classes -
i). An abstract class „student‟ with data member roll no, reg no and a abstract method course()
ii). A subclass „kiitian‟ with course() method implementation
Q2). Define an interface Motor with a data member –capacity and two methods such as run() and consume(). Define a Java class "Washing machine" which implements this interface and write the code to check the value of the interface data member thru an object of the class.
Q3). Define an interface with three methods – earnings(), deductions() and bonus() and define a Java class „Manager‟ which uses this interface without implementing bonus() method. Also define another Java class „Substaff‟ which extends from „Manager‟ class and implements bonus() method. Write the complete program to find out earnings, deduction and bonus of a sbstaff with basic salary amount entered by the user as per the following guidelines –
earnings = basic + DA (80% of basic) + HRA (15% of basic)
deduction PF = 12% of basic
bonus = 50% of basic

Lab 9

Topics

  • Package in Java
  • String handling in Java

Q1). Define two packages as – General and Marketing. In General package define a class „employee‟ with data members as empid(protected), ename(private) and a public method as earnings() which calculate total earnings as
earnings = basic + DA (80% of basic) + HRA (15% of basic)
In Marketing package define a class „sales‟ which is extending from „employee‟ class and has a method tallowance() which calculates Travelling Allowance as 5% of total earning. Write the programs to find out total earning of a sales person for the given basic salary amount and print along with the emp id.
Q2). Write a program to perform following operations on user entered strings –
i) Change the case of the string
ii) Reverse the string
iii) Compare two strings
iv) Insert one string into another string
Q3). Program on Dynamic Method Dispatch.

Lab 10

Topics

  • Exception handling in Java
  • ArithmaticException, ArrayIndexOutofBoundsException,
  • NullPointerException
  • User defined exception in Java

Q1). Write a Java program to generate an ArrayIndexOutofBoundsException and handle it using catch statement.
Q2). A subclass exception must appear before super-class exception. Justify this with suitable Java programs.
Q3). Write a Java program to illustrate try..catch..finally block.
Q4). Write a Java class which has a method called ProcessInput(). This method checks the number entered by the user. If the entered number is negative then throw an user defined exception called NegativeNumberException, otherwise it displays the double value of the entered number.
Q5). Write a program to create user defined exceptions called HrsException, MinException and SecException. Create a class Time which contains data members hours, minutes, seconds and throw the user defined exceptions if hours (>24 & <0),minutes(>60 & <0),seconds(>60 & <0).
Q6). Create an user defined exception named Check Argument to check the number of arguments passed through command line. If the number of arguments is less than four, throw the Check Argument exception, else print the addition of squares of all the four elements.
Q7). Write a java program to create Account with 500 rupee minimum balance, deposit amount, withdraw amount and also throws LessBalanceException which returns the statement that says withdraw amount is not valid.
Q8). Write a java program to implement a stack class having methods push () and pop(). These methods must be designed to throw user defined exception when the stack is empty or full.
Q9). Write a java program to justify “A subclass exception must appear before super-class exception”.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published