Upload
sai-sandeep
View
217
Download
0
Embed Size (px)
Citation preview
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 1/18
What is the purpose of serialization?Answer: Serialization is the conversion of an object to a series of
bytes, so that the object can be easily saved to persistent storageor streamed across a communication link !he byte stream canthen be deserialised " converted into a replica of the originalobjectSource # $%ample
What is the di&erence between '() and '*$?Answer: 'ava (evelopment )it +'() is the most widely used 'avaSoftware (evelopment )it 'ava *untime $nvironment +'*$ is animplementation of the 'ava -irtual .achine, which e%ecutes 'ava
programsSource # '() Wiki # '-. Wiki
What is the di&erence between e/uals+ and 0112 ?Answer: $/uals is intended to check logical e/uality and 11checks if both references point to same object +!hanks Sandeepa == b; // Compares references, not values.
a.equals(b); // Compares values for equality.
Source
When will you use 3omparator and 3omparable interfaces?Answer: javautil3omparator and javalang3omparable
javautil3omparator compares some other class4sinstances, while javalang3omparable compares itself withanother object
Source # $%ample
What is the wait5notify mechanism?Answer: !his deals with concurrent programming !he wait+ andnotify+ methods are designed to provide a mechanism to allow a
thread to be block until a speci6c condition is met7owever, javautilconcurrent should be used instead of wait+and notify+ to reduce comple%itySource # 'ava A89 # 'ava !echnical Article
What is the di&erence between checked and uncheckede%ceptions?
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 2/18
Answer:9n general, unchecked e%ceptions represent defects in theprogram +bugs, which are normally *untime e%ceptionsurthermore, checked e%ceptions represent invalid conditions inareas outside the immediate control of the programSource
What is the di&erence between 6nal, 6nally and 6nalize?Answer: A 6nal variable cannot be modi6edb A 6nal method cannot be overriddenc A 6nal class never participates in 9nheritance
06nally2 is a block of code that always e%ecutes when the tryblock is 6nished, unless Systeme%it+ was called 6nalize+ is anmethod that is invoked before an object is discarded by thegarbage collector
Source # inal ;sage #inally ;sage # inalize+
What is the di&erence between web server and app server?Answer: A Web server e%clusively handles 7!!8 re/uests,whereas an application server serves business logic to applicationprograms through any number of protocolsSource
What is the di&erence between forward and sendredirect?Answer: <oth method calls redirect you to newresource5page5servlet !he di&erence between the two is thatsend*edirect always sends a header back to the client5browser,containing the data in which you wanted to be redirectedSource
7ow does a = tier application di&er from a > tier one?Answer: !iers are the physical units of separation or deployment,while layers are the logical units of separation9magine that you4re designing an ecommerce website A = tierarchitecture would consist of web pages, a web server and adatabase, with the corresponding = layers being the08resentation2, 0<usiness @ogic2 and 0(atabase2 layers9f you take the database tier and layer out then your have a > tierarchitectureSource
7ow does the version control process works?Answer: 9nitiate, pull, branch, merge, commit, push
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 3/18
+9nit .ake your own repository +8ull (ownload an e%istingrepository from a url +<ranch 5 .erge .ake revisions 3ommitthen push your modi6cationsit 3heat Sheet
What is the di&erence between 'A* and WA* 6les?Answer: 'A* 6les +'ava A*chive allows aggregating many 6lesinto one, it is usually used to hold 'ava classes in a libraryWA* 6les +Web Application a*chive stores B.@, java classes, and 'avaServer pages for Web Application purposesSource
What is a @eft outer join?Answer: !his deals with SC@ @eft outer join preserves theunmatched rows from the 6rst +left table, joining them with a
D;@@ row in the shape of the second +right tableSource # 'oins Wiki
What is the di&erence between ;D9ED and ;D9ED A@@?Answer: !his deals with SC@ ;D9ED only selects distinct values,;D9ED A@@ selects all valuesSource # $%ample
Why main() in java is declared as public static void main?
What if the main method is declared asprivate?
Ans : <ecause, every program start e%ucution from mainfunction!he static method can directly call without createing theobject of the classSo, before createing object the main functionruns and then it creates object
And, public in main method due to access by '-. 9f the methodis private then '-. cannot call that function!he program will
compile but never run9t show the message F.ain method notpublicF
2.What is Externalizable?
Ans : !his interface is used for serialization!o save the state of an
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 4/18
object in 6le 9t provides two methodread$%ternal+ and write$%ternal+
3.What modiers are allo!ed for methods in an "nterface?Ans : abstract and public
#.What are the di$erent identier states of a %hread?
Ans :* *unning or *unnableS Suspended.S !hread Suspended on .oniter lock.W !hread waiting on moniter3W !hread waiting on condition variable
&.What are some alternatives to inheritance?
Ans : (elegation is an alternative to inheritance (elegationmeans that you include an instance of another class as aninstance variable, and forward messages to the instance 9t isoften safer than inheritance because it forces you to think abouteach message you forward, because the instance is of a knownclass, rather than a new class, and because it doesn4t force youto accept all the methods of the super class: you can provide only
the methods that really make sense En the other hand, it makesyou write more code, and it is harder to reuse +because it is not asubclass
'.Why isnt there operator overloadin?
Ans : <ecause 3GG has proven by e%ample that operatoroverloading makes code almost impossible to maintain
*.What does it mean that a method or eld is +static,?
Ans : Static method or 6eld are member of class!hey do notneed any object for call or access We can directly call the staticmethod and 6elds without using the object
-. "s ava /ass by 0eference or /ass by 1alue?
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 5/18
Ans : 9ts always pass by value
-. What is the purpose of arbae collection in ava and!hen is it used?
Ans : arbage collection is a special feature in java language 9thelps developer to save time and e%tra mental tension forhandling object allocation in memory 9t automatically clean theunused object from memory which helps to allocate space atruntime When there is no reference to an object found, it willclean that object from memory Hou can run the garbagecollection e%plicitly by using System.gc()
-. What is ar4er interface? 5o! is it used in ava?Ans : .arker interface is an interface which help us to notify few
information to '-.53ompiler !he marker interface does not haveany body, it4s a empty interface $% 3loneable, Serialization, etc
-. 6an you ive fe! examples of nal classes dened in ava 7/"?Ans: String, 9nteger ,loat ,etc <asically all wrapper classed are6nal
-. What is the importance of init() method in 8ervlet?
Ans: init+ method is one of the life cycle method of servlet !hismethod runs once in total life After servlet instance created andbefore it handles re/uest the init+ method will work 9ts basicallyused for initializing values at the time of application startup
-. 5o! to improve 8ervlet /erformance ?Ans: Hou need to do few tuning for this achievement ew pointsbelow :I ;se init+ method for all e%pensive operation duringinitialization +may be static data or cached data
> Always avoid auto loading of servlet= Avoid Single!hread.odelJ ;se and control 7ttpSession properly
-. 5o! can a servlet refresh automatically if some ne!data has entered the database?Ans : <asically it depends on the scenario , how you can handle
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 6/18
Hou need handle this in dao layer, when doing insert operationyou can call an utility method which will load the conte%tServlet3onte%t@istener <ecause, servlets are basically used forhandling re/uest and give the response
-. 5o! does 8/ handle run9time exceptions?Ans: Hou can use is$rror8age12true2 in page attribute
-. What is an E: 6ontext?Ans: !he $'<3onte%t interface provides an instance with access tothe containerprovided runtime conte%t of an enterprise beaninstance
-;. Why do you !ant to !or4 in this industry < company?
Ans: irst you should try to convince that this company giveshuge opportunity in many aspect ie new technologiesimplementation, the policy of company suits you likeprofessionalism Also you can mention that you are big fan ofthis company and its your dream company <asically show yourall positive attitude towards company
-2. Which location do you !ant to !or4 in and !hy?
Ans : ive your own choice Also mention a valid reason for why
you are interested for that location !he reason should be alwayspositive and clear $%ample : you can support your family fromthis location,
-3. =escribe a problem you faced and ho! you deal !ithit ?
Ans : Hou can describe any issue you faced during your projectwork in the organization And what the solution you haveimplemented for that issue
-#. What are the types of class loaders in ava?
Ans : As per my knowledge there are basically = types of classloader like bootstarp classloader,e%tension class loader andsystem class loader
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 7/18
<ootstrap 3lass @oader<ootstrap class loader loads java4score classes like javalang, javautil etc !hese are classesthat are part of java runtime environment <ootstrap classloader is native implementation and so they may di&eracross di&erent '-.s
$%tensions 3lass @oader'A-AK7E.$5jre5lib5e%t contains jarpackages that are e%tensions of standard core java classes$%tensions class loader loads classes from this e%t folder;sing the system environment propery javae%tdirs you canadd Le%t4 folders and jar 6les to be loaded using e%tensionsclass loader
System 3lass @oader 'ava classes that are available in the java classpath
are loaded using System class loader
-'. 5o! to read and !rite imae from a le ?
Ans : Hou can use 9mage9oread+ and 9mage9Ewrite+ method of java%imageio package
-*. What is di$erence bet!een static and init bloc4 in java.
Static does not need any object to execute. Before creating any object thestatic block can execute as we are using in static method. So, here thestatic block is call at the time of JVM execution , means before creating theobject( when first time JVM execute . But !nitiali"ation block is call#loadede$ery time when object is created.%hene$er the object is created at thattime the !nitiali"ation block is loaded.
->. 5o! 6oncurrent5ashap !or4s?
Ans : !he basic design of 3oncurrent7ash.ap is to handling
threading <asically it locks each of the bo% +by default IM whichcan be locked independently and thread safe for operation And itdoes not e%pose the internal lock process
What is 6oncurrentap and ho! it !or4s?
Ans " 9t4s a .ap which providing thread safety and atomicity
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 8/18
guarantees or .emory consistency it works with otherconcurrent collections, actions in a thread prior to placing anobject into a ConcurrentMap as a key or value happen-
before actions subse/uent to the access or removal of that objectfrom the ConcurrentMap in another thread
-. 6an a static bloc4 thro! exception?
Ans : Hes We can throw checked e%ception
-;@. What is di$erence bet!een iterator access and indexaccess?
Ans : <asically iterator access process the traverse operationthrough each element, where inde% access process access direct
the element by using the inde%
-;;. Why character array is better than strin for storinpass!ord in java?
Ans : <ecause, character array stores data in encrypted formatwhich is not readable by human <ut,the string stores the data inhuman readable format which is not secure
-;2. !hat is daemon thread in java ?
Ans : A daemon thread is normally runs on background And itdoes not prevent the '-. from e%iting when the program 6nishesbut the thread is still running
-;3. What is ava 0eAection 7/"?
Ans : *eNection is one of the most powerful api which help towork with classes, methods and variables dynamically <asicallyit inspect the class attributes at runtime Also we can say it
provides a metadata about the class
-;#. What is the di$erence bet!een 8erializable andExternalizable interfaces?
Ans : <oth interfaces are used for implement serialization <ut,the basic di&erence is Serializable interface does not have any
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 9/18
method +it4s a marker interface and $%ternalizable interfacehaving > methods such as read$%ternal+ and write$%ternal+Serializable interface is the super interface for $%ternalizableinterface
What is transient variable ?
Ans : !ransient variables are not serializable 9t helps to avoid avariable to being serialization
#) Write the code to initialize the inner class members.
Ans : 3ode here
public class 9nner3lass!est O
class inner!estO private int ageP
public void display+O Systemout println+FAge1FGageP Q Q
5RR R param args R5 public static void main+StringTU args O 9nner3lass!estinner!est innerEbj1new9nner3lass!est+new inner!est+P innerEbjage1>VP innerEbjdisplay+P QQ
&) 5o! to retrieve the elements from the collection !ritethe code ?
Ans : 'ava provides certain interfaces by using that we canretrieve the elements from collection$%ample " 9terator,@ist9terator and $numeration
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 10/18
$%ample : Array@ist data retrival
public class Array@ist*etrive O
5RR
R param args R5 public static void main+StringTU args O Array@istStringX ar@ist1new Array@istStringX+P ar@istadd+F'avaFP ar@istadd+FisFP ar@istadd+F8owerfulYYYFP
55*etrive elements from Array@ist using 9terator 9terator i!er1ar@istiterator+P
while+i!erhasDe%t+O Systemout println+i!erne%t+P Q Q
Q') What is static and instance variables and methods ?
Ans : Static variables are per class but the instance variables areper object All object share a single copy of static variable 9n case
of static method , no need of object creation for calling staticmethod !he static method can directly call by using class name9nstance method need object for calling*) What is dynamic loadin and static loadin of java class?
Ans : (ynamic class loading is by 3lassforDame+ , which loadsthe class dynamically Also you can use reNection for dynamicclass loading <ut, the static class loading is working by usingLnew4 keyword
>) What type of loadin is class.forname() ?
Ans : 9ts dynamically locate and loads the class
) What is 5ibenate 3 best bents ?
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 11/18
Ans : !here are many bene6ts of hibernate <ut the most bene6tsare below :
I 9t reduces the developer e&ort to writing /ueries> 9ts easy to use with relational object which maps with java
class and database relation= Cuery tuning is not re/uired and it implements separatescache which is reason for better performance
;@) " have ;@@ tables and elds. " !ant to nd one tablename and column names. Write a Buey .
Ans : 9 have used mySC@ database for this below /ueryselect !A<@$KS37$.A,!A<@$KDA.$,3E@;.DKDA.$ frominformationKschema3E@;.DS where !A<@$KDA.$1Z$.8@EH$$ZP
;;) 5o! to dene a eld name in hibernate usinannotation ?
Ans: 3olumn +9ts provided by java persistent A89
;2) What is 8ynchronization ?
Ans: Synchronization is a solution for concurrency issue 'ava provide ZsynchronizedZ keyword for implementing this
;3) %he most commonly used classes in collectionsn ?
Ans : Array@ist, @inked@ist, 7ash!able, 7ash.ap and3oncurrent7ash.ap, etc
3. 5o! many types of literals are there in 717 ?
Ans : !he literals means the value you are assigning to variable
Hou can specify the below types of literal in javaAs per theprimitive data types+int,short,long,Noat,double,boolean,char ,etcthere is respective literal Some literal needs to be ended with aspeci6c character*ead .ore
long var1>V@P 55specify @ or l for long literalint var1>VP 55 9f not mentioned any character then its can be
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 12/18
short or intchar var14A4PNoat var1IVJJfP 55specify f or for Noat literaldouble var1IVJJPboolean var1trueP 55or false
#. What is meant by Carbae collection ?
Ans : arbage collection is a automatic feature of java forcleaning the unused object from heap 9t helps to developer forreleasing the reserved memory without any e%tra e&ort bydeveloper 9t helps developer to save time and e%tra mentaltension for handling object allocation in memory When there isno reference to an object found, it will clean that object from
memory Hou can run the garbage collection e%plicitly by usingSystem.gc()
&. =i$ference bet!een strin sD ne! strin () and strins D F5i =udeF ?
Ans : <oth statements are di&erent to each other Always Lnew4keyword is used to create object
String s=new String(); 55 !his statement creates new object in
heap S is the object hereString s=”Hi Dude” ; 55 !his statement do not create object, itscreating reference and its storing in String 3onstant 8oolS is thereference here
'. What is sinleton class? !here is it used ?
Ans : 8inleton desin pattern is the most useful pattern in realtime scenarioSingleton pattern will ensure that there is only one
instance of a class is created in the '-.!his implementationrestrict the user to create multiple access point or instance !hisis a creational design pattern 9t has many implementation over java language, but singleton is an anti9pattern or badpractice
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 13/18
*. What is the di$erence bet!een 8/ and 8ervlets ?
Ans : As simple 'S8 is precompiled but Servlets are not 'S8 isspecially use for displaying5populating the data on browser 9f wetake an e%ample of .-3 architecture 'S8 plays the role of -iew
+- <ut, Servlets are used to handle the re/uest and process thebusiness logic 9n .-3 architecture Servlets are knows as3ontroller +3
>. What is the di$erence in usinreBuest.et0eBuest=ispatcher() andcontext.et0eBuest=ispatcher()?
Ans : <oth are taking String parameter, butre/uestget*e/uest(ispatcher+ will dispatch the re/uest inside
the application Where as conte%tget*e/uest(ispatcher+ willdispatch the re/uest outside the conte%t also 9f you are usingabsolute path for dispatching then both are similar
. 5o! the 8/ le !ill be executed on the 8erver side ?
Ans : irst its converted to java 6le !hen its compiled by javacompiler and creates the class 6leDow once you get the class6le you can e%ecute it 9nternally a 'S8 converts into respectiveservlet
3onversion 1X 3ompilation 1X $%ecution
;2. What is the di$erence bet!een the 8ession and8essionGactory in hibernate ?
Ans : Session and Sessionactory are playing a prominent role inhibernate Sessionactory is used to create Session and its
created once during starting of the application Hou can have onlyone Sessionactory per application Sessionactory is also called>ndlevel cache <ut, Session could be many per applicationSession is being created by using Sessionactory objectSession iscalled Ist level cache
;3. What is 5-H ?
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 14/18
Ans : 7C@ stands for 7ibernate Cuery @anguage 9ts fully objectoriented and /uite similar with SC@9t supports association and joins for e&ective entity relationship
Which "nterface is used to ma4e duplicate of Ibjects ?
Ans " 3loneable interface
-;;) What are some advantaes and disadvantaes of ava 8oc4ets?
Ans " !he main advantage is its Ne%ible and very e[cient duringlow network bandwidth Also its helpful for debugging and some
kind of testing <ut, security is the most disadvantages 9tsalways recommended to be careful when authenticating
-;2) When can an object reference be cast to an interfacereference?
Ans "Hes its possible, when that interface is implemented by thatclass
$%ample " .y9nterface obj1new .y3lass+P
objcall.ethod+P
-;3) 5o! does ava allocate stac4 and heap emory?
Ans " As we know stack memory is not dynamic and its follows@9E order 'ava provides similar implementation for memoryallocation Dormally all local variables are created in Stack area+memory and objects +reference types are created in heapmemory +heap area $ven all primitive types allocated in stackmemory 7eap area is dynamic and handled by '-. runtime
7eap memory is cleaned by garbage collector at runtime
-;#) What is memory lea4 in ava?
Ans " ;sually memory leak leads to waste of memory 9n generalmemory leak de6nes the unavailability of referenced memory 9tcauses the arbage collector to fail to collect that object
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 15/18
-;&) 6an !e thro! exception from nally bloc4 in ava?
Ans " Hes, but you need to mentioned 0throws2 on the methodhead
Eamp!e " &ublic static $oid main(String' args throws )xce&tion *## +- uto/generated method stub+est!nterface0 interbj1new !nterfacebject(2
try*interbj.dis&lay(23catch()xce&tion e*
System.out.&rintln(4)xce&tion handled...423finally*throw new )xce&tion(4+his is exce&tion4233
-;') 5o! does ava handle inteer overAo!s andunderAo!s?
Ans " Hes, java handles overNows and underNows very
intelligently When it overNows it will go to .9DK-A@;$ +ie >=I
and when it underNows to will go to .ABK-A@;$ +ie >=II
-;>) What is castin?
Ans " 3asting means conversion <asically we need casting totype cast the type !here are two types of casting by java iee%plicit casting and implicit casting
-;) What is ne! in 8/?
Ans " As per my knowledge 'S8 >I has many new functionalities9t support resource injection via annotation 9t has few e%tendedsupport for java standard tag library Also literal e%pression issupported by 'S8 >I $@ and many other additional features
-2@) What do you mean by ava 0eAection ?
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 16/18
Ans " 9t provides runtime access to '-. *eNection is one of themost powerful A89 which help to work with classes, methods andvariables dynamically at runtime <asically it inspects the classattributes at runtime Also we can say it provides a metadata
about the class
-2;) Why does the "nput8tream0eader class has aread() ?
Ans " <ecause, an 9nputStream*eader is a bridge from bytestreams to character streams: 9t reads bytes and decodes theminto characters using a speci6ed charset !he charset that ituses may be speci6ed by name or may be given e%plicitly, or theplatformZs default charset may be accepted 9t has two
overloaded read+ method $ach invocation of one of an9nputStream*eaderZs read+ methods may cause one or morebytes to be read from the underlying byteinput stream !o enablethe e[cient conversion of bytes to characters, more bytes maybe read ahead from the underlying stream than are necessary tosatisfy the current read operation
-.;. 5o! you can dene an object ? 5o! its related to
real !orld and it behaves ? With Example.
Ans : As we know object is a real world entity 9t has three basicproperty ie State" #eha$ior and %dentity.
8tate: what the ob&ects ha$e (og have a name, age, color,etc 9tis implemented by variables in java
:ehavior: what the ob&ects do(og can bark, bite, run, etc 9t isimplemented by methods in java
"dentity: what ma'es them uniue, (og have iduni/ue, which isuni/ue +this is important when implementing the e/uals method,to determine if the objects are di&erent or not $very object hasdi&erent hash code
Example Suppose , there are many dogs <ut, you canZt say ,
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 17/18
that is an object Hou need to take one dog which has name dick,age\,color white and it must have a uni/ue identi6cationAnd now we can say dick is a dog object And this dick can bark,bite and run !hese are the behavior that object can do, and in itsimplemented by methods
-.2. 5o! many contructor J methods are in Ibject class ?
Ans: !here are only one constructor and nine methods in Ebjectclass 9ts available inside &a$a.!ang package
6onstructor K9public Ebject+ ethods K9
c!one() - his create and return copy of the same ob&ect.
eua!s() - his is used to compare some other ob&ect is eua! tothis or not.toString() - *on$ert and return a string representation.
+na!i,e() - his is ca!!ed by garbage co!!ector when there are nomore acti$e reference to that ob&ect eist. get*!ass() - his returns the runtime c!ass of this ob&ect. hash*ode() - eturns an hash code for this ob&ect and its uniue. notify() - a'es up a sing!e thread that is waiting on this ob&ect/s
monitor. notify0!!() - a'es up a!! thread that is waiting on this ob&ect/smonitor. wait() - his wi!! ma'e ob&ect to wait " unti! any other threadnotify this.
-.3. Why !ait() and notify() method is inside Ibject classinstead of %hread class ? Ans : <ecause, wait+ and notify+ method works with multi
threaded environment !his is inside Ebject class because, we aredoing the monitoring work over an Ebject When ever we arecalling these methods , we are calling over object , not on thread
-.#. 5o! many !ays !e can create object in ava ?
Ans : !here are basic four way for creating object in java as below
8/16/2019 What is the Purpose of Serialization
http://slidepdf.com/reader/full/what-is-the-purpose-of-serialization 18/18
:
:y usin ne! 4ey!ord 91b&ect ob&=new 1b&ect();:y usin class.forLame() 9
Dog dog1b&=( Dog )c!ass.for2ame(3&de$e!operguide.!ab.Dog3).newt%nst ance();
:y usin deserialization 9ObjectInputStream inStream = new
ObjectInputStream(anInputStream);
Dog dogObject = (Dog ) inStream.readObject();
:y usin clone() 9
Dog dog1b&=new Dog();Dog dog1b&4=dog1b&.c!one(); 55%t must imp!ement c!onnab!einterface.
-.&. 5o! 1 allocates object in memory ? What is heapand stac4 memory ?
Ans : Dormally objects are allocated on heap memory 7eapmemory is a dynamic memory which increase and decrease thesize on run time All primitive types,methods are allocated on
stack memory All object type and reference types are allocatedon heap area$very thread creates a stack +call stack and whenthread completes the stack is also release the reserve memory !he stack is faster compare to heap