Вы находитесь на странице: 1из 6

2/23/2015

Javainterviewquestionsandanswerspart2

Javainterviewquestionsandanswerspart2

Javainterviewquestionsandanswerspart2 Search Interview Currentaffairs Civilservices Banking
Javainterviewquestionsandanswerspart2 Search Interview Currentaffairs Civilservices Banking
Search
Search
Coverletter Aptitude English Onlinetest Askquestion! ►JavaPDF ►JavaInterviewQuestions ►JavaSourceCode
Coverletter Aptitude English Onlinetest Askquestion! ►JavaPDF ►JavaInterviewQuestions ►JavaSourceCode

►JavaPDF

►JavaInterviewQuestions

►JavaSourceCode

Javainterviewquestionsandanswerspart2

The==operatorcomparesreferencesandnotcontents.Itcomparestwoobjectsandiftheyarethesameobject

inmemoryandpresentinthesamememorylocation,theexpressionreturnstrueelseitreturnsfalse

Astaticvariableisattachedwiththeclassasawholeandnotwithspecificinstancesofaclass

GarbagecollectionisalsocalledautomaticmemorymanagementasJVMautomaticallyremovestheunused

variables/objects(valueisnull)fromthememory

Abstractclasscanhaveaconstructor.Butaswecan'tinstantiateabstractclass,wecan'taccessitthroughthe

object

AddressingPortability:Manycomputersofdifferenttypeswithseveraloperatingsystemsareconnectedto

network/internet

Theintegerandfloating­pointtypesaredifferentintermsoftheconsumptionofthebitswhichrepresentthem.

Therearecertaindatatypeswhicharerightlyaptforspeed

Javaomitsrarelyused,poorlyunderstoodfeaturesthoseareavailableinC++.Thesefeaturesincludeoperator

overloading,multipleinheritance,destructors,allocationandfreeingofmemory

JavabytecodecanrunonanyOSwithjavainstalled.JVMtakescareofexecutingofnativebytecode

Javaprogramminglanguage,Javaclassfileformat,JavaApplicationProgrammingInterface,Javavirtual

machine

machine Readanswer Interviewquestions Javainterviewquestions JavaFAQs
machine Readanswer Interviewquestions Javainterviewquestions JavaFAQs

Interviewquestions

JNI

JMS

RMI

2/23/2015

Javainterviewquestionsandanswerspart2

AJavaclasshasattributes,staticblocks,non­staticblocks,constructors,methodsandinnerclasses.Fields:

Fieldsarereferredtodatamemberswhomaretobeaccessedbythemethods,constructorsofthesameclass

andmethodsofotherclasses

Aconstructorisablockofcodewiththesamenameofitsdefiningclasswithoutreturntype

Ex:Employee(){…}//TheclassnameisEmployee

Instancemembersaretheattributesandmethodsofaclass.Theyshareonecopyeachperobject.Sincean

objectisaninstanceofaclass,memoryhasbeensetasideforeachobjecttocontainitsowncopiesofinstance

members

Apackageisagroupof.classfiles.

The.classfilesareorganizedintonamespaces.ThejavapackagesarecompressedintofilesknownasJava

Archivefiles

Garbagecollectionistheprocessofreclaimingheapmemoryspacebyremovingorphanobjects

Theobjectsthatarenolongerneededbytheapplicationaregarbagecollected

Garbagecollectionisdoneautomatically

Thekeyword‘super’isusedforreferringparentclassinstance

Samedatamembersofsuperclasshidesthevariablesbythesubclass

Ex:super.number;//numberofsuperclassisaccessed

Ex:super.number;//numberofsuperclassisaccessed Readanswer Spring JavaTransactionAPI–JTA JBOSS
Javadesignpatterns Javalocalization

Javasupportstodefinetwoormoremethodswithsamenameswithinaclass.

Allthemethodsshoulddifferineitherbythenumberortypeofparameters.

ThemethodSystem.out.println()receivesmultipleparameters

StringClass:

TheStringclassisimmutable.

ThecontentsoftheStringobjectcannotbechanged.

Stringclassisfinalclass.Thatimpliesitcannothavesubclasses.

Stringobjectscanbeconcatenatedbyusing+and+=operators

InnerClass:Aclassdefinedinsideanotherclassiscalledan‘InnerClass’.

Typesofinnerclasses:

Classes,interfaces,methods,instancevariablescanbeinspectedatruntimebyusingreflectionclass

Toinspecthenamesoftheclasses,methods,fieldsetc.neednotbeknown

ReflectioninJavaispowerfulanduseful,whenobjectsareneededtobemappedintotablesinadatabaseat

runtime

Platformindependent:Swingisplatformindependentinbothexpressionandimplementation

Extensible:Allowspluggingofcustomimplementationsofspecifiedframeworkinterfaces.Userscanprovide

customcomponentimplementationsbyoverridingthedefaultimplementations

2/23/2015

Javainterviewquestionsandanswerspart2

Alayoutmanagerorganizestheobjectsinacontainer

Differentlayoutsareusedtoorganizeortoarrangeobjects

AuserdefinedexceptionisextendedbyExceptionclass.

Unconventionalactionsaredealtwithuserdefinedexceptions

ApplicationdemandedexceptionsotherthanAPIsaredefinedasuserdefinedexceptions.Ex:Whenthebalance

ofanaccountisbelowzeroafterwithdrawl,anexceptioncanberaisedlike‘NegativeBalanceException’

Threadsareusedinjavaby

a.extendingtheThreadclass

b.implementingtheRunnableinterface

StreamClasses:Theyarebyte­oriented,TheyneversupportUnicodecharacters,Supports8­bitstreams

PersistingthestateofanobjectinastoragemediaisknownasObjectSerialization

Savingandretrievingdataisoneofthecriticaltasksfordevelopers

Bypersistingobjects,applicationscanefficientlyhandlethem,asonlyoneobjectcanbeusedatagivenpointof

time

Thefollowingarecertaincharacteristicsthatsocketshare:

1.Thesocketisavailableaslongasthenetworkprocessmaintainsanopenlinktothesocket

2.Asocketcanbenamedinordertocommunicatewithothersocketsinanetwork

3.Communicationisperformedbythesocketsinnetworkwhentheserverreceivestheconnectionsand

requestsfromthem

TheimportantinterfacesinJDBCare:

java.sql.DriverManager:UsedtomanageJDBCdrivers,thusestablishesaconnectiontothedatabaseserver

java.sql.Connection;Usedforestablishingconnectiontoadatabase.AllSQLstatementsexecuteswithinthe

connectioncontext

Endiannessistheprocessoforderingtheaddressablesubunitssuchaswords,bytesorbitsinalongerword

thatistostoreinanexternalmemory

Toenableacomputersystemforstoringtextandnumberswhichisunderstandablebyhumans,thereshouldbe

acodethattransformscharactersintonumbers

Aloopisasetofstatementsthatissupposedtorepeatoneormoretimes.Javasupports3loops

Thekeyword‘new’isusedforcreationofobjects.Primitivetypesaretouseconstantsbutnotobjects

2/23/2015

Javainterviewquestionsandanswerspart2

Thefinalize()methodofjavaisinvokedbyJVMtoreclaimtheinaccessiblememorylocation,Whenthe‘orphan’

object(withoutreference)istobereleased,JVMinvokesthefinalize()method,whenthenext

Theequals()methodisdefinedinStringclassinordertotestwhethertwostringsvaluesaresamesequenceof

characters.Themethodisforexclusivelytestingstringobjects,butnotanyotherobjects

Astringobjectthatiscreatedusing“String”classisimmutable.Thecharactersoftheobjectcannotbechanged/

modified.Therearesomemethods,suchassplit(),substring(),beginsWith()etc

Primitivetypescanbepassedbyreference.1.Bystoringtheprimitivetypevalueinanarrayofsingleelementand

passingit

Asignatureinjavaisacombinationofelementsinalistsuchasconstructorandmethodstherebydistinguishing

themfromotherconstructorsandmethods

Astaticnestedclasscannotdirectlyaccessnon­staticmethodsorfieldsofaninstanceofitsenclosingclass.

Theycanbeaccessedbycreatingtheobjectofthenestedinnerclass.Whereasnon­staticnested

Aninstancevariablecanbedeclaredasprivatetopromoteinformationhiding

Overriddenmethodsofsuperclassinsubclassallowaclasstoinheritandbehavecloseenough.Toavoid

namingconflictandsignatureandtypeandnumberofparameters

Thejavaaccessspecifier‘protected’isplacedproceedingthememberoftheclassandtheaccesscontrolis

applicableonlyforthatparticulardefinition

EveryexceptionisrepresentedbytheinstanceofThrowableoritssubclasses.Anobjectcancarrythe

informationfortheexceptionraisingpointtotheexceptionhandlerwhichcatchesit

Whenanexceptionistobehandledwhicharenotjavaclasslibrary,auserdefinedexceptioncanbethrown.An

exceptioncanbethrownexplicitly,whenaconditionismet.Inotherwords,inasituation

Onceanapplicationfindsanexception,respondsanexceptionbythrowinganotherexception.Itcausesanother

exception.Knowinganexceptionthatcausesanotherexceptionisveryuseful

Thetermexceptionletstheprogrammertoknowthatthereissomethingexceptionalhasoccurredinthe

program.ApartfromJavaexceptionclasslibrary,acustom

2/23/2015

Javainterviewquestionsandanswerspart2

Primitivetypewrapperclassesorsimplywrapperclassesareavailableinjava.langpackageforprovidingobject

methodsforalltheeightprimitivetypes.Allthewrapperclassobjectsareimmutable

Inanapplication,aprogramcontinuestorununtilallofthethreadshaveended.Hence,themainthreadtofinish

atlastisnotarequirement.Itisagoodprogrammingpracticetomakeittorunlasttofinish

Javathreadscanbecreatedgraciouslyintwoways:implementingtheRunnableinterfaceandextendingThread

class

Inmultipleprocessorsystems,alargealgorithmwillsplittheprocessintothreads.Sothatdifferentprocessors

canhandledifferentthreads

Enumerationistypesafe.Whereasfinalvariablesarenot.Enumerationsupportstohaveablendofvarious

values

YesIispossibleforamethodotherthanpaint()orupdate()tooutputanapplet’swindow.Itismandatoryto

obtainagraphicscontextbyinvokinggetGraphics()method

ThecompiledJavasourcecodeisknownasbytecode.Javacompilergeneratesthebytecode.Thebytecode

canrunonanyplatform/machineregardlessofthesystem’sarchitecture

Javastrictlyspecifiestherangesforprimitivevalues.Theselectionofvaluesinintegerorfloatingpointtypes

differsbasedontherequirementofanapplication

ThechardatatypeinJavaisasingle16­bitUnicodecharacter.Itrepresentsacharacterthatcouldbeanyoneof

theworldlanguages

Theprefixoperator++addsonetoitsoperand/variableandreturnsthevaluebeforeitisassignedtothe

variable.Inotherwords,theincrementtakesplacefirstandtheassignmentnext

ThemethodindexOf()returnsthefirstoccurrence(index)ofagivencharacteroracombinationasparameterina

givenstring

Thedefaultaccessspecifierisonewhichisnotspecifiedwithakeyword.Ifnoaccessspecifier(anyoneof

private,protected,public)ismentioneditisknownasthedefaultaccessspecifier

2/23/2015

Javainterviewquestionsandanswerspart2

2/23/2015 Javainterviewquestionsandanswerspart2 Writeyourcomment­ShareKnowledgeandExperience DiscussionBoard
2/23/2015 Javainterviewquestionsandanswerspart2 Writeyourcomment­ShareKnowledgeandExperience DiscussionBoard
2/23/2015 Javainterviewquestionsandanswerspart2 Writeyourcomment­ShareKnowledgeandExperience DiscussionBoard

DiscussionBoard

DiscussionBoard thanksforinterviewquestions veryhelpfultofreshersbatch muralijillellamudi12­3­201212:29PM thanksalot.

thanksforinterviewquestions

veryhelpfultofreshersbatch

muralijillellamudi12­3­201212:29PM

thanksalot.

muralijillellamudi12­3­201212:29PM thanksalot. Home | Aboutus | Sitemap | Contactus
muralijillellamudi12­3­201212:29PM thanksalot. Home | Aboutus | Sitemap | Contactus
muralijillellamudi12­3­201212:29PM thanksalot. Home | Aboutus | Sitemap | Contactus
muralijillellamudi12­3­201212:29PM thanksalot. Home | Aboutus | Sitemap | Contactus

Copyright©2008­2015CareerRide.com.Allrightsreserved. Termsofuse | FollowusonFacebook!

Bookmarkto:

Termsofuse | FollowusonFacebook! Bookmarkto: http://www.careerride.com/Java­Interview­page­2.aspx 6/6
Termsofuse | FollowusonFacebook! Bookmarkto: http://www.careerride.com/Java­Interview­page­2.aspx 6/6
Termsofuse | FollowusonFacebook! Bookmarkto: http://www.careerride.com/Java­Interview­page­2.aspx 6/6