0% found this document useful (0 votes)
3 views

Programming q

The document outlines coding conventions for a Java Employee class, emphasizing the importance of naming conventions for packages, classes, variables, and methods. It provides examples of how to create and manipulate Employee objects while adhering to these conventions. Additionally, it includes tasks for creating Employee instances and displaying their data using various methods.

Uploaded by

truptinik27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming q

The document outlines coding conventions for a Java Employee class, emphasizing the importance of naming conventions for packages, classes, variables, and methods. It provides examples of how to create and manipulate Employee objects while adhering to these conventions. Additionally, it includes tasks for creating Employee instances and displaying their data using various methods.

Uploaded by

truptinik27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Points:

1. Don’t use default package

2. Class name should not be Demo,Test,X,A,B

3. Variable names should not be a,b,c

4. Variable names should start with small latter

5. Every variable should be private except local

6. Method names should not be m1,m2

7. Method names should start with small latter

public class Employee {

private int id;

private String name;

private int sal;

public Employee(int id, String name, int sal) {

super();

this.id = id;

this.name = name;

this.sal = sal;

public Employee() {

public int getId() {

return id;
}

public void setId(int id) {

this.id = id;

public String getName() {

return name;

public void setName(String name) {

this.name = name;

public int getSal() {

return sal;

public void setSal(int sal) {

this.sal = sal;

Notes : whenever I say Employee class, refer to this class.

1.Create Employee class with fields id,name and sal and create Employee object and store data and display that data.

2.public class Demo {


public static void main(String[] args) {

//here create object of Employee class and add 101,sam,1000 data into that

//display that data here

3. public class Demo {

public static void main(String[] args) {

//here create object of Employee class and add 101,sam,1000 data into that using setter method

//display that data here

4. public class Demo {

public static void main(String[] args) {

//here create object of Employee class and add 101,sam,1000 data into that using constructor

//display that data here

5.public class Demo {

public static void main(String[] args) {

//here create object of Employee class and add 101,sam,1000 data into that

//call show method and pass this created object to show method

public static void show(){

//do required changes to show method and display that data here

}
}

6.public class Demo {

public static void main(String[] args) {

//here create object of Employee class and add 101,sam,1000 data into that

//call show method and pass this created object to show method

public void show(){

//do required changes to show method and display that data here

7. public class Demo {

public static void main(String[] args) {

//here create two objects of Employee class and add data into that

//call show method and pass this two objects to show method

public static void show(){

//do required changes to show method and display that data here

8. Find the output

public class Demo {

public static void main(String[] args) {

Employee emp = new Employee(101, "sam", 1000);


Demo.show(emp);

System.out.println(emp.getId()+" " + emp.getName() + " "+ emp.getSal());

public static void show(Employee ex) {

System.out.println(ex.getId() + " " + ex.getName() + " " + ex.getSal());

ex.setId(102);

9.

public class Demo {

public static void main(String[] args) {

//create Employee object with 101,sam,1000 data

//display this object data by passing to show method

//add 100 bonus in salary

//display this object data by passing to show method

public static void show(){

//do required changes in show method

}
10.

public class Demo {

public static void main(String[] args) {

//create Employee object with 101,sam,1000 data

//display this object data by passing to show method

//add 100 bonus in salary

//display this object data by passing to show method

public void show(){

//do required changes in show method

You might also like