Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please view this: java questions!!!

 
Jerome Laggad
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello to all Java Aficionado out there...
I just want to ask help from you. This are my java questions:
1. What is the difference between "class" and "object"?
2. Can we write java programs in non-OO way?
3. Can we make "private" the "toString()" method in constructor?
3. What is the difference between abstract class and interface? Why use abstract class and interface?
4. What is "Encapsulation" in SQL?
5. Can we use the keyword "strictfp" as modifier to classes, variables, or methods?
6. Can we use "private" as access level to constructor?
7. What is primitive data tpye?
 
Gjorgi Var
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as the first two questions are concerned:
1. Class is a blueprint for the object, and objects are instances of a class. If you have ever seen "Full Metal Jacket", recall that scene when future marines go to bed with their rifles, saying:"THIS IS MY RIFLE! THERE ARE MANY LIKE IT, BUT THIS ONE IS MINE!!!". "Rifle" is a class, "my rifle" is the object of the class "rifle". There are many instances of "rifle"("THERE ARE MANY LIKE IT,..."), but that one is a special ("...BUT THIS ONE IS MINE!"), sets apart from others, is unique instance... every object is a unique instance of a class...
2. You can absolutely proceed with no-OO spaghetti cooking in Java, no problem... in that case forget about reusability of your code, encapsulation, inheritance...
As far as the other questions are concerned, I think that there are people far more proficient in Java than me...
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jerome Laggad:
hello to all Java Aficionado out there...
3. Can we make "private" the "toString()" method in constructor?

Not sure what you are asking here? If you onlymean if you can make toString() method private, the answer is NO; as overriding requires you to make methd more public and less restrictive acces modifier is not allowed.

4. What is "Encapsulation" in SQL?

I am also interested in knowing the answer.
Regarding other answers, refer to any basic Java book. Thinking in Jaa might be a god idea.
HTH,
- Manish
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Beginners forum....
 
Deepesh Makkar
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jerome Laggad:
hello to all Java Aficionado out there...
I just want to ask help from you. This are my java questions:
1. What is the difference between "class" and "object"?
2. Can we write java programs in non-OO way?
3. Can we make "private" the "toString()" method in constructor?
3. What is the difference between abstract class and interface? Why use abstract class and interface?
4. What is "Encapsulation" in SQL?
5. Can we use the keyword "strictfp" as modifier to classes, variables, or methods?
6. Can we use "private" as access level to constructor?
7. What is primitive data tpye?

Answer to 6th Question
V can ofcoz use private as access specifier to constructor, but v wont b able to create an object of such a class from outside the class itself. This is wat is done in Singleton pattern
7 Question:
primitive data types r data types which dont have associated classes with them and u cant create objects of such data types(such as int) but we can of coz use Wrapper classes to wrap them to objects
 
Nick George
Ranch Hand
Posts: 815
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to 6th Question
V can ofcoz use private as access specifier to constructor, but v wont b able to create an object of such a class from outside the class itself. This is wat is done in Singleton pattern
7 Question:
primitive data types r data types which dont have associated classes with them and u cant create objects of such data types(such as int) but we can of coz use Wrapper classes to wrap them to objects

I mean the writer of this statement no offense, but moderators, for the mental health of forum users, isn't there some way to censure such bastardization of the English language?
"V can ofcoz"
u,(v?),coz,b,wat,r,dont,cant.
I had to cringe multiple times while reading that post, and is that fair to a loyal forum attender? Coz doesn't even sound like a short version of becuase, at least say cus.
I try to keep my linguistic purism in check, and I'm all for a completely open forum to all walks of life, but can't moderators encourage a certain level of common decency?
While I'm on such a tirade,
"please view this" makes no sense as a subject (afraid I'll just ask the thread on a date?), and neither does "java" (this is a java forum). Thus, if you feel like giving as nebulous of a name as possible, leave it at "questions." I'll even let you keep your exlamation points.
Tirade over. Excuse me, I've had a bad day.
[ April 19, 2004: Message edited by: Joseph George ]
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but v wont b able

It's so uncool.
Only children around there?
I agree with Joseph G.!
I'm no native english speaking person, and have difficulties reading such bzows�ief.
There are enough people, writing a more poor english than me, and I guess they will suffer from these cryptic engliz more than me.
It should be an issue for the nettiquette.
---
to the questions:
No. 5: No. What shall that be - strictfp?
No. 7: In my opinion, the only primitive datatype is boolean, but I'm not sure about that.
[ April 20, 2004: Message edited by: Stefan Wagner ]
[ April 20, 2004: Message edited by: Stefan Wagner ]
 
Nick George
Ranch Hand
Posts: 815
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nah, chars, ints, longs, floats, doubles, bytes... all primative. if you don't say
<blank> thing = new <blank>(), it's primative.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph - I see, you didn't work too much with ints, chars etc.
They aren't so primitiv as they look like...
int a, b:
a > 0;
b > 0;
a+b < 0;
 
Tim West
Ranch Hand
Posts: 539
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JLS Section 4.2 says that a primitive is, as Joseph says, one of boolean, int, byte, char, long, short, float, double.
-Tim
 
Nick George
Ranch Hand
Posts: 815
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
short... that's a good one, i forgot about that one
stefan, that code doesn't make any sense. just thought i'd throw that out there
[ April 21, 2004: Message edited by: Joseph George ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic