• 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
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Peter Rooke
Bartenders:

help with this q

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello could someone help me with this question please?
thanks
cat
What's an immutable object? What are some examples of immutable objects?
Why is immutability important in Java? How would you create an immutable
class?
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
immutable object are the objects which cannot be changed.
Example of immutable object is java.lang.String class
immutability is important in java for security reasons.
make the class variables as final to make the class immutable
 
cat lukes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help. Would it be ok to ask you a couple more questions?
Thanks again
cat
 
subhit chauhan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sure cat...
not assigned any projects till now so you can go ahead and can ask questions....
if i know you will definitely get a reply..
 
cat lukes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Subhit
This is my first question.
What is design by contract? What are the different ways to implement it
in a method using the latest Java language spec.?
what is the adaptor design pattern.

What is the difference between composition and inheritance.
What is a weak reference?

Thanks again subhit for your time
cat
 
subhit chauhan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
design by contract is a theory, according to which a software project or a software system is viewed as a set of communicating components whose interaction with each other is based on precisely defined specifications i.e. some contracts.
It is a systematic approach to build a bug free software project...
Adaptor Pattern is one of the design pattern. I never used that so i dont know... If you want you can check out this link http://www.patterndepot.com/put/8/JavaPatterns.htm
composition means putting and class inside a class... i.e. the way in which we model objects which contains other objects is with composition.
and inheritance is extending the functionality of already existing class by extending your class with it... making a parent and child relationship..
a weak reference is one that does not prevent the referenced object from being garbage collected...
 
cat lukes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again
I have a couple more questions if you dount mind.
I did check out that link you gave me but it get given me an error i will try again then i will search .
What does this question mean?
Can you create and compile class which do not invoke Object's
constructor? Can you run it?
and my last question is
What is the difference between abstract and interface? When to use
which one?
Thanks for your time
Cat
 
subhit chauhan
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didnt got exactly what the question means...
object of any class you wanna create, if that class dont have its own constructor then the java runtime calls the java.lang.object class's constructor, that means java.lang.Object class is the parent of all the classes whether you extend your class from it or not.... its extended by default...
If you dont want your class to be instantiated then you can create one private constructor
private constructors is being used in Singleton Design Pattern
when you dont know the full functionality of a behaviour of an object and dont want to instantiate a class, you give common functionality and leave the rest for the child class to provide the implementation.... thats where you make the parent class an abstract and the method which you want your child class to implement.
but this reduces ones ability for multiple inheritance for which one used interfaces...
 
cat lukes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again
one more and that is the lot
How would you store a primitive type in a Collection such as a List?
Thanks
Cat
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- put it in a wrapper object
or
- create an array of length 1 of the primitive type and add the primitive array

maybe you can get bonus marks for the array solution, but really, using the object wrapper class is the best solution.
Jamie
[ April 15, 2003: Message edited by: Jamie Robertson ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic