answersLogoWhite

0


Best Answer

This is the Num objects class

public class Num{

public int number; // makes the integer that will store the number

public Num(int a){ //constructor

number = a; //number being stored

}

public void setNumber(int b){ //New Method that will edit number

number = b;

}

public int getNumber(){ //New Method that will return number

return number;

}

}

This is the class that edits and add the object

public class FindNum{

public static void main(String[] args){

Num example = new Num(5); //creates an object of the class Num and sets the int number to 5

example.setNumber(7); //set the new value to 7

System.out.print(example.getNumber()); //returns the value and prints it

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What will be a simple program to explain object in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a simple java code and explain what the code does?

int a;This simple Java statement declares an integer.


Can you initialize an object without constructor in java?

No. if you wish to create an object that you plan on using in a java program then the answer is NO. You cannot initialize an object of a Java class without calling the constructor.


What are the names of different part of simple java program?

NO!


Why java is certifiction?

java is a object oriented langage,that is indepentant platform. java is full object oriented language. java is access any operating system.so java is good certification of program in runtime environment.


What mutable and immutable in java and example program?

lmutable object


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


What has the author Stephen Gilbert written?

Stephen Gilbert has written: 'Object-oriented design in Java' -- subject(s): Java (Computer program language), Objektorientierte Programmierung, Java (Programmiersprache), CD-ROM, Systementwurf, Object-oriented programming (Computer science) 'Object-oriented design in Java' -- subject(s): Java (Computer program language), Object-oriented programming (Computer science)


Where can one find more information on Java car rental?

Java Car Rental is an opensource program which you can find on various forums across the net, though the best place to learn how to create this program is Rose India. They offer the code and explain the variables you can tweak for your business - it is actually quite simple, and there are various places to go for tutorials that explain how you can tweak this program to your liking.


What is the basic of java?

java buzzwords like simple , Secure , Portable, Object-Oriented, Robust, Dynamic, etc............


What has the author David D Riley written?

David D. Riley has written: 'The object of Java' -- subject(s): Computer software, Development, Java (Computer program language), Object-oriented programming (Computer science) 'The Object of Java, BlueJ Edition'


Hi friends i am new to java can you explain how java is secured?

java is an object oriented programme it is similar to c++ so if you know very well in c++ you can easily figure it out.


Writing a program in a language such as c plus plus or java is known as what?

Object Oreinted Programming