• Post Reply Bookmark Topic Watch Topic
  • New Topic

classes in java  RSS feed

 
irrfan jamadar
Greenhorn
Posts: 10
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why to write everything in class.Can anyone tell me with real life example.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Well, the answer's simple. Java is an object-oriented language, and in a class is the only place it allows you to write code. So you don't need an example to demonstrate that.

If you mean, "why is it designed that way", that's a huge question that we're not going to be able to effectively answer here. I'd suggest reading a tutorial on object-oriented programming to get an idea of how it works.

If you've got some more specific questions we might be able to help you.
 
irrfan jamadar
Greenhorn
Posts: 10
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.But Can I know which tutorial or book you suggest me for understanding this concept like why everything should go into class.what will happen if we will not use class.This question was asked in interview.
 
Palak Mathur
Ranch Hand
Posts: 343
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
irrfan jamadar wrote:Thanks for your reply.But Can I know which tutorial or book you suggest me for understanding this concept like why everything should go into class.what will happen if we will not use class.This question was asked in interview.


Hi Irrfan,

In Java everything goes inside a class because it is how it is meant to be so that OOO features can be utilized fruitfully. You will need to go through the OO Concepts. I would recommend you to buy t Head First Object-Oriented Analysis & Design and go through it and all your basics regarding this issue will get resolved. IF you still face issues then come back here and ask your specific questions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!