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

Assignment No.1

ITS ABOUT JAVA PROGRAMMING

Uploaded by

Writers Heart
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)
8 views

Assignment No.1

ITS ABOUT JAVA PROGRAMMING

Uploaded by

Writers Heart
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/ 2

ASSIGNMENT NO.

Name: Rutchel L. De La Cruz Date: August 14, 2024

Block No: 07

1. In my point of view, a programmer’s primary tasks is to write and modify code to create software solutions.

2. Programming is the process of designing and building instructions for computers to execute specific tasks.

3. Object-Oriented Programming is a programming paradigm that organizes software design around objects and data rather than

actions and logic.

4. OOP is applied to create modular, reusable, and maintainable code by encapsulating data within objects and defining

interactions between objects.

5. A class is a blueprint in creating objects, all code in a Java program must belong to a class. Classes define the types for objects;

hence, objects are sometimes referred to as instances of their defining class, because they take on the name of that class as their

type. We declare a ‘class’ keyword followed by a class name.

public class Counter {

6. Class names should start uppercase letter and follow CamelCase naming conventions.

7. The main “actors” in Java program are objects. Objects store data and provide methods for accessing and modifying this data.

Every object is an instance of a class, in which defines the type the object, as well as the kinds of operations that it performs.

8. A method is a function defined within a class to perform specific actions. Methods can accept parameters as arguments, and

their behavior depends on the object they belong to and the values of any parameters that are passed. Every method in Java is

specified in the body of some class. A method definition has two parts: the signature, which defines the and parameters for a

method, and the body, which defines what the method does. A method allows a programmer to send a message to an object.

The method signature specifies how such a message should look and the method body specifies what the object will do when it

receives such a message. We declare methods in Java by specifying the method signature within the class. The syntax in

defining methods are as follows:

The syntax for defining a method is as follows:

// method body …

9. Method name should start with a lowercase letter and follow camelCase naming conventions.

10. A constructor is a special method used to initialize objects when they are created.

// constructor body …

11. Constructors have the same name as the class and do not have a return type.

12. Create a Java program that demonstrates the use of constructors and methods. The class should model a basic entity with

attributes and provide functionality through methods.


public class Entity {
private String name;
private int age;
//Constructor
public Entity(String name, int age){
this.name = name;
this.age = age;
}

//Method to display information


public void displayInfo(){
System.out.println ("Name:" + name);
System.out.println ("Age:" + age);
}

public static void main(String[]args){


Entity entity = new Entity("Rutchel", 19);
entity.displayInfo();
}
}

This program defines a class Entity with attributes name and age, a constructor to initialize these attributes, and a

method displayInfo to print the entity’s information. In the main method, an instance of Entity is created and its information

is displayed.

You might also like