classes

classes

what is meant by class?why we use class?what is the purpose of class?what is the main theme of class?tell clearly?plz...

View Answers

February 3, 2011 at 12:08 PM

Hello Friend,

A class is a blue print through which an object is created. In Java, all things are based on class and object.

class Person {

       String name = "";
       int age = 0;

       void changeName(String name1) {
            name = name1;
       }

       void changeAge(int age1) {
            age = age1;
       }
            void print() {
            System.out.println("Name:"+name+"\nAge:"+age);
       }
}
class PersonInformation{
    public static void main(String[]args){
    Person p=new Person();
    p.changeName("B");
    p.changeAge(20);
    p.print();
    }
}

The design of this class is based on the person objects. The fields name and age represent the state of object, and the methods- changeName and changeAge define its interaction with the outside world.The Person class does not contain a main method as it is just the blueprint for persons that might be used in a program.The class PersonInformation takes the responsibility of creating and using person objects.

Thanks

Ads









Related Tutorials/Questions & Answers:
DAO Classes
DAO Classes  login page code for Dao classes
wrapper classes
wrapper classes  Explain wrapper classes and their use?   Java Wrapper Class Wrapper class is a wrapper around a primitive data type... of the primitive wrapper classes in Java are immutable i.e. once assigned a value
Advertisements
classes
classes
classes and objects
classes and objects  Define a class named Doctor whose objects... methods, and an equals method as well. Further, define two classes: Patient... classes a reasonable complement of constructors and accessor methods, and an equals
Inner classes
Inner classes   Hi I am bharat . I am student learning java course . I have one question about inner classes . question is how to access the instance method of Non-static classes which is defined in the outer
ml classes
ml classes  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: ml classes Try to provide me good examples or tutorials links so that I can learn the topic "ml
ai classes
ai classes  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: ai classes Try to provide me good examples or tutorials links so that I can learn the topic "ai
Helper classes in java
Helper classes in java  helper classes
classes in c++
classes in c++  1- design and implement a class datatype that implement the day of the week in the program.the class datatype should store the day, such as sun for sunday. the programe should be able to perform the following
Classes and Objects
Classes and Objects       Objects and classes are the fundamental parts of object-orientated programming technique. A class... illustrates how to define our own classes, that includes declaring and defining
Hibernate Classes
In this section, you will learn about persistent classes in Hibernate
ModuleNotFoundError: No module named 'classes'
ModuleNotFoundError: No module named 'classes'  Hi, My Python... 'classes' How to remove the ModuleNotFoundError: No module named 'classes... to install padas library. You can install classes python with following command
Anonymous Inner Classes - Anonymous Inner Classes tutorial
.style1 { text-align: center; } Anonymous Inner Classes Except the inner class, there are two types of supplementary  inner classes... inner classes. The class declared inside the body of a method without naming
Java list of uninstantiated classes
Java list of uninstantiated classes  Java list of uninstantiated classes
Presistace classes in hibernate
Presistace classes in hibernate  Explain the persistence class in hibernate
Classes in Java
Classes in Java       Exceptions: There are some kind of errors that might occur during the execution of the program. An exception is an event that occurs and  interrupts
Action classes in struts
Action classes in struts  how many type action classes are there in struts   Hi Friend, There are 8 types of Action classes: 1.ForwardAction class 2.DispatchAction class 3.IncludeAction class 4.LookUpDispatchAction
GWT supported java classes
GWT supported java classes  What are the methods and classes in Java which are supported and unsupported by GWT
Collection classes in java
Collection classes in java   Normally a database is used... is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project
Collection classes in java
Collection classes in java   Normally a database is used... is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project
Nested and Inner classes
Nested and Inner classes  What is the significance of Inner Classes and Static Inner Classes? or Why are nested classes used?   Hi Friend... nested classes because of the following reasons: It is a way of logically
about predefine classes.....
about predefine classes.....  how we know that the class used in your given examples are predefind and from where we get info. about other predefine classes. we need explanation about examples given by you for java beginners
Java application that uses the classes and
Java application that uses the classes and   i have this class diagram with three classes: Curriculum, Course, and Lecture. Your class diagram...) I wish Write a Java application that uses the classes and methods above
Small business administration classes
administration classes is important in learning the important techniques? Thanks... administration classes from any reputed training company will help you in your business. The Small business administration classes will help you in following
online classes for data science
online classes for data science  Hi, I am beginner in Data Science... classes for data science Try to provide me good examples or tutorials links so that I can learn the topic "online classes for data science". Also
data analytics classes online
data analytics classes online  Hi, I am beginner in Data Science... analytics classes online Try to provide me good examples or tutorials links so that I can learn the topic "data analytics classes online". Also tell me
ai classes near me
ai classes near me  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: ai classes near me... the topic "ai classes near me". Also tell me which is the good training
Member Classes, Inner Nested Classes in java
Member Classes        Member classes are defined within the body of a class. We can use member classes anywhere within the body of the containing class. We declare member classes
how many types of system classes are there?
how many types of system classes are there?  How many types of system classes
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program

Ads