Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

WORKSHEET EVALUATION

Experiment 1.1

Student Name: Rohan Godha UID: 20BCS1762


Branch: CSE Section/Group: CSE6-B
Semester: 3 Date of Performance: 02/09/2021
Subject Name:JAVA PROGRAMMING LAB
Subject Code: 20CSP-219

Aim/Overview of the practical:


Studying Constructors in Java

Task to be done/ Which logistics used:


Write a program to study different types of constructors in java

Operating System: Windows


Software: VS Code

Algorithm/Flowchart (For programming based labs):


i) Start.

ii) Create public class constructor.

iii) Create functions to ask and read the name and UID of user.

iv) Print Them with and without use of Parameters.

v) End.
Steps for experiment/practical/Code:
import java.util.Scanner;

class Default{

Default(){

System.out.println("******Constructor Without Parameters******");

System.out.println();

System.out.println("Enter deatails of student "); }}

class Parameterised {

Parameterised(String id, String name){

System.out.println("******Constructor With Parameters******");

System.out.println();

System.out.println("Name is "+name+" Student id is "+id); } }

class Ab{

private Ab(){

String a; }

Ab(String b){

String a=b;

System.out.println();

System.out.println("This is private "+a); } }

public class constructor {

public static void main(String[] args) {

Default a1=new Default();

System.out.println("Uid =");

Scanner sc=new Scanner(System.in);

String uid = sc.next();

System.out.println("Name = ");

String name = sc.next();

Parameterised a2=new Parameterised(uid,name);


Ab a3=new Ab("class"); } }

Observations/Discussions/ Complexity Analysis:


The code executed properly and gave expected output.

Result/Output/Writing Summary:

Learning outcomes (What I have learnt):


I have learn to use constructors in Java.

Evaluation Grid (To be created as per the SOP and Assessment guidelines by the
faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.

You might also like