aspose file tools*
The moose likes Beginning Java and the fly likes Regarding Java Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding Java Object" Watch "Regarding Java Object" New topic
Author

Regarding Java Object

Bala jee
Ranch Hand

Joined: Sep 22, 2007
Posts: 35
Im basically a C Programmer and Im very new to java i need to know about oops concepts can you expain me about that.
Like
what is object and what is class?
Why we need class and Objects?
is instance and object one and the same?
...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

a class is like a blueprint. it tells you what's IN the thing, and what the thing can DO.

an object is one of the (possibly) many things you build from that blueprint. they'll be very similar, but one may have blue paint, and another red, but both have an outside_color.

in C terms, a class is like your struct definition - you list each element and type. but you also declare methods on that struct, that make sense to that struct.

so, if i made a person struct, it might have (i'm not trying to get the exact right syntax here):

struct person {
string first_name;
string last_name;
date birthdate;
}

in Java, you can add methods to the thing (still not going for correct syntax):

class person {
string first_name;
string last_name;
date birthdate;

/*this method will return the first and last name concatenated as*/
*a single string */
public string get_name();

/* this method will use the person's birthdate and the current */
/* system date to calculate the person's age, and return that */
public int get_age();
}


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Bala jee
Ranch Hand

Joined: Sep 22, 2007
Posts: 35
Why we need class and Objects?
is instance and object one and the same?

The above two questions are not still answered can any one explain me these also?
Srikanth Iyer
Ranch Hand

Joined: Apr 30, 2007
Posts: 52
java unlike C is a Object-orineted programmming lang.....

that means it helps you visualize the program in real-life terms..........

YOU would have learnt struct and data-structures in C.....

the main problem with record structures is that the library designer cannot hide the implementation of the lobrary without affecting the clent code because the code is often tied to the particular detalis of the data structures.

So by the 1980 object oriented programming or oops came ....


The main advantage of ooop was the ability to hide the data......

The combination of data attriubtes and procedures(called methods) are known as a class......
Bala jee
Ranch Hand

Joined: Sep 22, 2007
Posts: 35
is instance and object one and the same?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Bala jee:
is instance and object one and the same?


Basically, yes. An instance is an object. An object is an instance (of a class).

We usually use the word "instance" to mean an object of a particular class, which is the subject of the discussion. The word "object" is used more to refer to an instance of any class. However, these are not rules, just tendencies.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Java Object
 
Similar Threads
Compiler question
serialize object
Void is Wrapper Class
Diff bet component and java file?
Do something when object changes