• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding Java Object

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
...
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
 
Bala jee
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is instance and object one and the same?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic