Вы находитесь на странице: 1из 15
Coverletter Aptitude English Onlinetest Askquestion! ►PDFDownload ►JavaPDF ►JavaProgrammingClass
Coverletter Aptitude English Onlinetest Askquestion! ►PDFDownload ►JavaPDF ►JavaProgrammingClass

►PDFDownload

►JavaPDF

►JavaProgrammingClass

►PDFDownload ►JavaPDF ►JavaProgrammingClass Interviewquestions Javainterviewquestions JavaFAQs
►PDFDownload ►JavaPDF ►JavaProgrammingClass Interviewquestions Javainterviewquestions JavaFAQs

Interviewquestions

700Javainterviewquestionsandanswers

QUESTION­WhatisbytecodeinthecontextofJava?

­ThetypeofcodegeneratedbyaJavacompiler

­ThetypeofcodegeneratedbyaJavaVirtualMachine

­ItisanothernameforaJavasourcefile

­Itisthecodewrittenwithintheinstancemethodsofaclass.

CoreJava interviewtest(72questions)new ­ByPradipPatil,LecturerIIMPMCA

Java (20questions)new ­ByPradipPatil,LecturerIIMPMCA

QUESTION­WhatisgarbagecollectioninthecontextofJava?

­Theoperatingsystemperiodicallydeletesallofthejavafilesavailableonthesystem.

­Anypackageimportedinaprogramandnotusedisautomaticallydeleted.

­Whenallreferencestoanobjectaregone,thememoryusedbytheobjectisautomaticallyreclaimed.

­TheJVMcheckstheoutputofanyJavaprogramanddeletesanythingthatdoesn'tmakesense.

JSP

EJB

JNI

JMS

RMI

QUESTION­WhatisdifferentbetweenaJavaappletandaJavaapplication?

­Anapplicationcaningeneralbetrustedwhereasanappletcan't.

­Anappletmustbeexecutedinabrowserenvironment.

­Anappletisnotabletoaccessthefilesofthecomputeritrunson

­Alloftheabove

QUESTION­YoureadthefollowingstatementinaJavaprogramthatcompilesandexecutes.

submarine.dive(depth);

Whatcanyousayforsure?

­depthmustbeanint

­divemustbeamethod.

­divemustbethenameofaninstancefield.

­submarinemustbethenameofaclass

QUESTION­Whichistrueaboutananonymousinnerclass?

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

­Itcanextendexactlyoneclassandimplementexactlyoneinterface.

­Itcanextendexactlyoneclassandcanimplementmultipleinterfaces.

­Itcanimplementmultipleinterfacesregardlessofwhetheritalsoextendsaclass.

QUESTION­Ifathreadistobedeclaredasadaemonthread,itmustbedeclaredbefore

­startmethod

­runmethod

­stopmethod

­none

QUESTION­UnderwhatcircumstancesmightyouusetheyieldmethodoftheThreadclass

­Tocallfromthecurrentlyrunningthreadtoallowanotherthreadofthesameorhigherprioritytorun

­Tocallonawaitingthreadtoallowittorun

­Toallowathreadofhigherprioritytorun

­Tocallfromthecurrentlyrunningthreadwithaparameterdesignatingwhichthreadshouldbeallowedtorun

QUESTION­WhichofthefollowingisthecorrectsyntaxforsuggestingthattheJVMperformsgarbage

collection

­System.free();

­System.setGarbageCollection();

­)System.out.gc();

­System.gc();

QUESTION­Whenmethoddefinedinsubclasswhichhassamesignatureasamethodinasuperclass,itis

knownasmethod

­Overloading

­Overriding

­Packing

­noneofthese

Javadesignpatterns Javalocalization

QUESTION­InanAWTorSwingcontainer,BoxLayoutplacesthecomponentsinwhichform?

1)lefttoright

2)toptobottom

3)righttoleft

4)bottomtotop

­1

­2

­1and2

­3and4

QUESTION­Aclassthatcannotbeasubclassiscalledas

­abstract

­parentclass

­Final

­noneofthese

class.

QUESTION­Whichmodelusedinswingcomponent?

­Modelviewcontroller

­Eventdelegationmodel

­Documentobjectmodel

­networkmodel

QUESTION­Whenseveralthreadsactonobjectsimultaneouslyandtheresultisreliablethenitisknownas

­Boxing

­Unsynchronized

­synchronized

­noneofthese

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

QUESTION­Allcollectionclassesinjava.utilpackageareimplementationclassesofdifferentinterfaces

­True

­False

QUESTION­DeflaterOutputStremandInflaterInputStreamclassesareavailableinwhichpackage?

­java.io

­java.util

­java.io.zip

­java.util.zip

QUESTION­Processofstoringtheobjectcontainintothefileisknownas

­synchronization

­serialization

­zip

­doping

QUESTION­Staticandtransientvariablecannotbeserialized

­Yes

­No

QUESTION­Allcomponentsfromjavax.swingaredevelopedin

­C++

­C

­pascal

­purejava

QUESTION­FileOutputStreamclassstorethedataintheformof

­character

­file

­bytes

­bit

QUESTION­Whatisthedefaultbuffersizeusedbyanybufferedclass?

­128bytes

­256bytes

­512bytes

­1024bytes

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Javainterviewquestionsandanswersforfreshersandexperienced

Simple,Object­Oriented,Robust,Distributed,Portable,Interpreted,Multithreaded,PlatformIndependent,Secure

WhatisJVM?Explainitsrolesandfunctions.

ExplainwhyJavaiscalledasPlatformindependentlanguage.ExplainhowJavaexecutableexecutesonanyplatformwhereJVMis

available

Javaprogramminglanguage,Javaclassfileformat,JavaApplicationProgrammingInterface,Javavirtualmachine

ExplainthefeaturesofJavaclass.ExplainFields,Methods,andAccessLevels.

WhatareaccessorsandmutatormethodsinaJavaclass?Explainwithexampleforeach.

Explaintheimportanceof'this'reference.Writeacodetodepictstheuseof'this'reference

ExplainstaticvariablesandstaticmethodsinJava.Provideanexampletoexplainthem

Whatisaconstructor?Explainthedifferencesbetweenmethodsandconstructor.

Differencesbetweenconstructorsandmethods.

Writecodetodepicttheuseofconstructor

Whatisinstancemembers?Explainwithanexample

Whatisinstancevariable?Explainwithanexample

Whatisinstancemethod?Explainwithanexample

Whatisstaticmember?Explainwithanexample

Whatisstaticvariable?Explainwithanexample

WhatareJavapackages?ExplaintheimportanceofJavapackages.

StepsforcreatingapackageinJava

Explainthepackagesaccessspecifier,i.e.private,protected,public,default

ExplainJavaGarbagecollector.Whygarbagecollection?BriefexplanationofGarbagecollectionalgorithms.

ExplaintheimportanceoffinalizersinJava.WritecodetodepicttheusesoffinalizersinJava

Explaintheimportanceof'super'keywordinJava.Writecodetodepicttheusesof'super'keyword­Thekeyword‘super’isusedforreferring

parentclassinstance

DefineMethodoverloading.Explainitsuses.ProvideacodesampletoexplaintheusesofMethodoverloading

DefineMethodoverriding.Explainitsuses.ProvideacodesampletoexplaintheusesofMethodoverloading

Differencebetweenoverloadingandoverriding

DescribeJavastringclass.ExplainmethodsofJavastringclass.ExplainthecharacteristicsofStringBufferclass­StringClass:TheString

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

classisimmutable,ThecontentsoftheStringobjectcannotbechanged,Stringclassisfinalclass.Thatimpliesitcannothavesub

classes

WhatisJavainnerclass?Explainthetypesofinnerclasses,i.e.Staticmemberclasses,Memberclasses,Localclasses,Anonymous

classes

Needofinnerclassincontextwithadapterclasses

ExplainfewWrapperClassesMethods

ExplainaboutJavareflectionclass.

WriteacodesampletodepicttheusesofJavareflectionclass

WhatisSwing?ExplaintheneedofSwing.

WritesomeimportantfeaturesofSwing.

DescribeJavaSwingclasshierarchy.

ExplaintheneedofLayoutmanager

ExplaindifferentlayoutmanagerinJava.­Alayoutmanagerorganizestheobjectsinacontainer,Differentlayoutsareusedtoorganizeorto

arrangeobjects

ExplaintheneedofExceptionhandling.

ExplaintheExceptionscategories,i.e.checkedanduncheckedexceptions.

ProvidethegeneralformofExceptionhandlingconstructswithexplanation

WhatisuserdefinedException?Explainwithanexample

WhatisMultithreading?Explainthelifecycleofathread.

ExplainhowtousethreadclassforMultithreadinginJava.Explainwithanexample.

WhatisRunnableinterface?ExplainhowtouseRunnableinterfaceforMultithreading.

Whatarethemethodsofthreadclassinjava?Explainthem

Canyourexplainthreadpriorities?

ExplaintheuseofStreams.

DifferencebetweenStreamclassesandReaderwriterclasses

ExplainanddemonstratetheuseofFile,RandomAccessFileclasses.

ExplaintheuseofReaderandWriterclasses

WhatisobjectSerialization?ExplaintheuseofPersistingobject.

DepictthestepofusingobjectDeserialization

Whatissocket?Explainthefeaturesofsocket.

ExplainthecharacteristicsofJavasocketclass.

ExplainServerSocketclasswithanexample

ExplainInetAddressclasswithanexample

ExplainDatagramSocketclasswithanexample

ExplainDatagramPacketclasswithanexample

PurposesofJDBCAPI

Describe4typesofJDBCdriversandtheircharacteristicswithusages.

StatethefunctionalitiesofimportantclassesinJDBCpackages.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

ExplainhowtouseJDBCstatementtoexecuteSQLqueries.Showinanexample

ExplainhowtousePreparedStatementtoexecuteparameterizedqueries.Showinanexample

WhatisJDBCCallableStatement?

WhatisbatchupdatesinJDBC?Explainwithanexample

WhatisbatchupdatesinJDBC?Explainwithanexample Readanswer Writeyourcomment­ShareKnowledgeandExperience
WhatisbatchupdatesinJDBC?Explainwithanexample Readanswer Writeyourcomment­ShareKnowledgeandExperience
WhatisbatchupdatesinJDBC?Explainwithanexample Readanswer Writeyourcomment­ShareKnowledgeandExperience

DiscussionBoard

javainterviewQuestions

Here'ssomemorejavaquestions:

1)Juniorjavadeveloper

a)Basicocjp(formerscjp)questions:

–Whatdoesstatic,finalmean,purposes; –Howmanyaccesibilitymodifiersexist?Pleasedescribethem. –Whydoyouneedamainmethod? –Howmanyconstructorscanyouhave? –Defineoverwritingandoverloading –GivejavaAPIimplementationsforoverwritingandoverloading –DescribetheStringclass–uniqueproperties –StringBuildervsStringBuffer –Collections:pleasedescribe,givesomeexamplesandcomparethemtoeachother –ArrayListvsVector –HashMapvsHashTable –What’satree –What’samap –Multithreading:describethemanagementinjava –What’sasemaphone? –Howmanystatesarethereforthreads?

–Describetheusageforsynchronizedword(2)

–Serializationinjava–adescritionandusage

–Garbagecollectioninjava–descriptionandusage

–Canyouguaranteethegarbagecollectionprocess?

b)Simpledesignpatternquestions:

–Singletonpleasedescribemainfeaturesandcoding

–Factorypleasedescribemainfeaturesandcoding

–Haveyouusedothers?pleasedescribethem

2)IntermediateandSeniorlevel–dependingonrateofgoodresponses,additionalquestionsto1):

http://centraladvisor.com/programming­2/java/java­developer­interview

Bogdan08­1­201210:34AM

Javainterviewquestionsandanswers

ExplaintheimportanceofDriverManager.

ThebasicservicetomanagesetofJDBCdrivers.

WhatarethemethodsinObject?

clone,equals,wait,finalize,getClass,hashCode,notify,notifyAll,toString

Defineanestedclass.

Ifallthemethodsofainnerclassisstaticthenitisanestedclass.

Whatisgarbagecollection?

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Reclaimingtheunusedmemorybytheinvalidobjects.Garbagecollectorisresponsibleforthisprocess

DifferencebetweenLinkedListandArrayList.

LinkedListaremeantforsequentialaccessing.

ArrayListaremeantforrandomaccessing.

Defineapackage.

Packagesprovideswidenamespaceabilityandallowstogroupsetofclassesintoasingleunit.

Raj12­5­201103:10AM

Javainterviewquestionsandanswers

ExplainthesignificanceofListIterator.

UsingListIteratoryoucaniteratebackandforth.

Canyouexplaininnerclass.

Ifthemethodsoftheinnerclasscanonlybeaccessedviatheinstanceoftheinnerclass,thenitiscalledinnerclass.

Canyouexplainthemeaningofaggregationandcomposition

Aggregation­Itisaspecialtypeofcomposition.Ifyouexposeallthemethodsofacompositeclassandroutethemethodcalltothe

compositemethodthroughits

reference,thenitiscalledaggregation.

Composition­Holdingthereferenceoftheotherclasswithinsomeotherclassisknownascomposition.

IsitpossibletoinstantiatetheMathclass?

Youcan’tinstantiatethemathclass.

Pankaj12­5­201103:10AM

Javainterviewquestionsandanswers

DefineLocale.

ALocaleobjectrepresentsaspecificgeographical,political,orculturalregion.

Howwillyouloadaspecificlocale?

ByusingResourceBundle.getBundle(…);

IsJVMacompileroraninterpreter?

Interpreter

CanyouexplaintheusagesofClass.forName()?

ItloadstheclassintotheClassLoader.ItreturnstheClass.Usingthatyoucangettheinstance(“class­instance”.newInstance()).

Inqaddsaquestion:Expainthereasonforeachkeywordof

publicstaticvoidmain(Stringargs[])

Akash12­5­201103:10AM

Javainterviewquestionsandanswers

Definereflection.

Reflectionallowsprogrammaticaccesstoinformationaboutthefields,methodsandconstructorsofloadedclasses.

Canyoutellmerangeofbyte?

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

128to127

HowtoinvokeexternalprocessinJava.

Runtime.getRuntime().exec(….)

Whatisthebestwaytofindoutthetime/memoryconsumingprocess?

Byusingprofiler

Rakesh12­5­201103:09AM

Javainterviewquestionsandanswers

Whatisskeletonandstub?Explaintheirpurposes.

Stubisaclientsiderepresentationoftheserver,whichtakescareofcommunicatingwiththeremoteserver.

WhatkindofthreadistheGarbagecollectorthread?

Daemonthread

ExplainthepurposeofVoidclass.

TheVoidclassisanuninstantiableplaceholderclasstoholdareferencetotheClassobjectrepresentingtheprimitiveJavatypevoid.

Nitin12­5­201103:09AM

Javainterviewquestionsandanswers

Explaintheimportanceoffinalizemethod.

Finalizemethodcleansupsomeresourcesbeforeitgetgarbagecollected.

Definemutableobjectandimmutableobject.

ThevalueofMutableobjectischangeable.

Ex.,StringBuffer

Thevalueofanimmutableobjectcan'tbechanged

Ex.,String,Integer,Float

WhatarethebaseclassforErrorandException?

Throwable

Dharam12­5­201103:09AM

Javainterviewquestionsandanswers

Differencebetweenstringandstringbufferobject.

Stringisanimmutableobject.

StringBufferisamutableobject.

Definedaemonthread.

Daemonthreadarethethreadswhichcanrunwithoutuserintervention.

TheJVMcanexitwhentherearedaemonthreadbykillingthemabruptly.

DefineaDatabaseMetaData.

Itrepresentscomprehensiveinformationaboutthedatabaseasawhole.

Jitu12­5­201103:08AM

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Javainterview

Explainpreemptiveschedulingandtimeslicing.

Inpreemptivescheduling,thehighestprioritytaskexecutesuntilitentersthewaitingordeadstatesorahigherprioritytaskcomesinto

existence.

Intimeslicing,ataskexecutesforapredefinedsliceoftimeandthenreentersthepoolofreadytasks.

ExplainthedifferentscopesforJavavariables.

3scopesofJavavariablesaredefinedbelow:

Instance

Initializedtodefaultvaluesatthetimeofcreationofobject,andremainaccessibleaslongastheobjectaccessible.

Local

DefinedwithinamethodandremainaccessbileonlyduringthecourseofmethodexcecutionandfalloutofscopeWhenthemethod

finishes

execution.

Static

Staticvariablesaretheclasslevelvariables.

StaticvariablesareinitializedwhentheclassisloadedinJVMforthefirsttimeandremainthereaslongastheclassremainsloaded.

Staticvariablesarenottiedtoanyparticularobjectinstance.

Akash11­23­201102:26AM

Javainterviewquestionsandanswers

Explainthepurposeoffinalization.

Itprovidesanunreachableobjecttheopportunitytoperformanycleanupprocessingbeforetheobjectisgarbagecollected.

Explaintheimportanceofdaemonthread.

Daemonthreadisalowprioritythread.

Itrunsintermittentlyinthebackgrounddoingthegarbagecollectionoperationforthejavaruntimesystem.

AdaemonthreadiscreatedusingsetDaemonmethod.

Synchronizedmethodsandsynchronizedstatements.

Synchronizedmethods

Methodsthatareusedtocontrolaccesstoanobject.

Athreadonlyexecutesasynchronizedmethodafterithasacquiredthelockforthemethod'sobjectorclass.

Synchronizedstatements

Theyaresimilartosynchronizedmethods.

Asynchronizedstatementcanonlybeexecutedafterathreadhasacquiredthelockfortheobjectorclassreferencedinthesynchronized

statement.

Nitin11­23­201101:31AM

Javainterviewquestionsandanswers

Whatarethewayofusingthread?

Canbeimplementedbyusingrunnableinterface

ByinheritingfromtheThreadclass.

Differencebetweenaconstructorandamethod.

Constructor

Aconstructorisamemberfunctionofaclassthatisusedtocreateobjectsofthatclass.

Ithasthesamenameastheclassitself.

Ithasnoreturntype,andisinvokedusingthenewoperator.

Method

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Amethodisanordinarymemberfunctionofaclass.

Ithasitsownname,areturntype,andisinvokedusingthedotoperator.

Explainhowtoserializeanobjecttoafile.

TheclasswhoseinstancesaretobeserializedshouldimplementaninterfaceSerializable,passtheinstancetotheObjectOutputStream

whichisconnectedtoafileoutputstream.Thiswillsavetheobjecttoafile.

Naveen11­23­201101:25AM

Javaquestionsandanswers

AccessSpecifiersinJava.

Public­publicclasses,methods,andfieldscanbeaccessedfromeverywhere.

Protected­

Protectedmethodsandfieldscanonlybeaccessedwithinthesameclass,withinitssubclasses,andwithinclassesofthesame

package.

Default(nospecifier)

Suchaclass,method,orfieldwillbeaccessiblefrominsidethesamepackagetowhichtheclass,method,orfieldbelongs,butnotfrom

outsidethispackage.

Private

Privatemethodsandfieldscanonlybeaccessedwithinthesameclass.

Privatemethodsandfieldsarenotvisiblewithinsubclasses

Theyarenotinheritedbysubclasses.

Explainstaticmethods.

Staticmethodsaredeclaredwiththekeywordstaticasmodifier.

TheyarecalledStaticbecausetheyaffectaclassasawhole,notaparticularinstanceoftheclass.

Theyarealwaysinvokedwithoutreferencetoaparticularinstanceofaclass.

Restrictionsofusingstaticmethods:

Itcanonlycallotherstaticmethods.

Itmustonlyaccessstaticdata.

Itcannotreferencetothecurrentobjectusingkeywordssuperorthis.

Priya11­23­201112:55AM

Javainterviewquestions

CanyoutellmethemainImplementationsoftheSetinterface?

HashSet

TreeSet

LinkedHashSet

EnumSet

ExplaintheimportanceofHashSet.

Itisanunsorted,unorderedSet.

Itusesthehashcodeoftheobjectbeinginserted.

Youcanuseitwhenyouwantacollectionwithnoduplicatesandyoudon’tcareaboutorderwhenyouiteratethroughit.

ExplaintheimportanceofTreeSet.

Itisasetimplementationkeepingtheelementsinsortedorder.

Theelementsaresortedaccordingtothenaturalorderofelementsorbythecomparatorprovidedatcreationtime.

Tina11­23­201112:46AM

Javainterviewquestionsandanswers

Definenativemethod.

AnativemethodisimplementedinalanguageotherthanJava.

Explainexplicitcasting.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

InExplicitcasting,thecomplierarespecificallyinformedabouttransformingtheobject.

Example

longa=890.20;

intb=(int)a;//Explicitcasting

Explainimplicitcasting.

Assigningoneentitytoanotherwithoutanytransformationguidancetothecompilerisimplicitcasting.

Thistypeofcastingisnotpermittedinallkindsoftransformationsandmaynotworkforallscenarios.

Example

inta=6000;

longb=a;//Implicitcasting

ExplainreflectionAPI

Reflectionistheprocessofintrospectingthefeaturesandstateofaclassatruntimeanddynamicallymanipulateatruntime.

ThisissupportedusingReflectionAPIwithbuilt­inclasseslikeClass,Method,Fields,Constructorsetc.

Example:UsingJavaReflectionAPIwecangettheclassname,byusingthegetNamemethod.

Rajeev11­22­201104:07AM

Javainterviewquestionsandanswers

ExplaintheimportanceofJavaVirtualMachine(JVM).

Itconverts.javafileinto.classfilebyusingCompilerandInterpreterreadsbytecodes.

ExplainthedifferenttypesofaccessmodifiersinJava.

Theydeterminethetypeofaccesstothememberofaclass.

Types:

­Public:accessibletoallclasses

­Protected:accessibletotheclasseswithinthesamepackageandanysubclasses.

­Private:accessibleonlytotheclasstowhichtheybelong

­Default:accessibletotheclasstowhichtheybelongandtosubclasseswithinthesamepackage

WhytherearenoglobalvariablesinJava?

Globalvariablesaregloballyaccessibleandhencecancreatecollisionsinnamespace.

WhatistheJavaAPI?

Italargecollectionofsoftwarecomponentsthatprovidecapabilities,suchasgraphicaluserinterface(GUI)widgets.

Rajeev11­22­201103:48AM

Javainterviewquestionsandanswers

ExplainStringTokenizer.

Itisutilityclassthatareusedtobreakupstring.

Example:

StringTokenizerstr=newStringTokenizer(“Welcome”);

while(str.hasMoreTokens()){

System.out.println(st.nextToken());

}

Nadeem11­22­201103:42AM

Javainterviewquestionsandanswers

Differencebetweentheboolean&operatorandthe&&operator.

Whenboolean&operatorisevaluated,bothoperandsareevaluated

&&operatorisashortcutoperator.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

When&&operatorisevaluated,thefirstoperandisevaluated.

Whenfirstoperandreturnsavalueoftruethenthesecondoperandisevaluated.

Whenfirstoperandevaluatestofalse,theevaluationofthesecondoperandisskipped.

Nadeem11­22­201103:40AM

Javainterviewquestions

DoesJavasupportpointers?

Javadoesn'tsupporttheusageofpointers.Improperhandlingofpointersleadstomemoryleakswhichiswhypointerconcepthasn't

foundplaceinJava.

SwingandAwt

AWTareheavy­weightcomponenets.

Swingsarelight­weightcomponentsandthisisreasonwhyswingworksfasterthanAWT.

Passbyreferenceandpassbyvalue

PassByReferenceisthepassingtheaddressitselfratherthanpassingthevalue.

PassbyValueispassingacopyofthevaluetobepassed.

RakeshS11­4­201101:26AM

Javainterviewquestions

Abstractclass

Itmustbeextendedorsubclassed.

Itactsasatemplate.

Itmaycontainstaticdata.

Aclassmaybedeclaredabstractevenifithasnoabstractmethodsandthispreventsitfrombeinginstantiated.

Annie11­4­201101:21AM

Annie11­4­201101:21AM Javainterviewquestionsandanswers­April18,2011

Javainterviewquestionsandanswers­April18,2011

Whatisanabstractmethod?

Anabstractmethodisamethodwhichdoesn’thaveabody,justdeclaredwithmodifierabstract.

Explaintheuseofthefinallyblock.

Finallyblockisablockwhichalwaysexecutes.Theblockexecutesevenwhenanexceptionisoccurred.Theblockwon'texecuteonlywhen

theusercallsSystem.exit()

Whatistheinitialstateofathread?

Itisinareadystate.

Whatistimeslicing?

Intimeslicing,thetaskcontinuesitsexecutionforapredefinedperiodoftimeandreentersthepoolofreadytasks.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

WhatareWrapperClasses?

WrapperClassesallowtoaccessprimitivesasobjects.

WhatisListinterface?

Listisanorderedcollectionofobjects.

Canyouexplaintransientvariablesinjava?

Theyarethevariablesthatcannotbeserialized.

Whatissynchronization?

Synchronizationensuresonlyonethreadtoaccessasharedresource,thuscontrolstheaccessofmultiplethreadstosharedresources.

Whatisserialization?

Serializationhelpstoconvertthestateofanobjectintoabytestream.

WhatisHashMapandMap?

MapisInterfaceandHashmapisclassthatimplementsthat.

Javainterviewquestionsandanswers­April20,2011

WhatisStringBufferclass?

StringBufferclassissameasStringclasswiththeexceptionthatitismutable.Itallowschangeanddoesn’tcreateanewinstanceon

changeofvalue.

Howcanyouforcegarbagecollection?

ItisnotpossibletoforceGC.WecanjustrequestitbycallingSystem.gc().

Isitpossibleanexceptiontoberethrown?

Yes,anexceptioncanberethrown.

Whatisthereturntypeofaprogram’smain()method?

Aprogram’smain()methodhasavoidreturntype.

Whichpackageisalwaysimportedbydefault?

Thejava.langpackageisalwaysimportedbydefault.

WhatisaClass?

Aclassimplementsthebehaviorofmemberobjectsbydescribingalltheattributesofobjectsandthemethods.

WhatisanObject?

Anobjectisthemembersofaclass.Itisthebasicunitofasystem.Ithasattributes,behaviorandidentity.

Explaintheuseof"instanceOf"keyword.

"instanceOf"keywordisusedtocheckthetypeofobject.

Howdoyourefertoacurrentinstanceofobject?

Youcanreferthecurrentinstanceofobjectusing"this"keyword.

WhatistheuseofJAVAPtool?

JAVAPisusedtodisassemblecompiledJavafiles.Thisoptionisusefulwhenoriginalsourcecodeisnotavailable.

Inwhichpackageistheappletclasslocated?

Appletclassesarelocatedin"java.applet"package.

Javaarrayvs.ArrayListclass.

ArrayListisadynamicarraythatcangrowdependingondemandwhereasJavaarraysarefixedlength.

ExplainEnumerationInterface.

Itdefinesthemethodsusingwhichwecanenumeratetheelementsinacollectionofobjects.

Whatareaccessmodifiers?

Accessmodifiersdetermineifamethodoradatavariablecanbeaccessedbyanothermethodinanotherclass.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Explaintheimpactofprivateconstructor.

Privateconstructorpreventsaclassfrombeingexplicitlyinstantiatedbycallers.

Whatisanexception?

Anexceptionisanabnormalconditionthatarisesinacodesequenceatruntime

Javainterviewquestionsandanswers­April21,2011

Whatarewaystocreatethreads?

Therearetwowaystocreateathread:

extendthejava.lang.Threadclass

implementthejava.lang.Runnableinterface

Howcanwestopathreadprogrammatically?

thread.stop;

Whataredaemonthreads?

Daemonthreadsaredesignedtoruninbackground.Anexampleofsuchthreadisgarbagecollectorthread.

WhatarethedifferenttypesoflocksinJDBC?

TherearefourtypesofmajorlocksinJDBC:

Exclusivelocks

Sharedlocks

Readlocks

Updatelocks

WhatareServlets?

Servletsareprogramthatrununderwebserverenvironments.

Whatarethedifferentwaystomaintainstatebetweenrequests?

Therearefourdifferentways:

URLrewriting

Cookies

Hiddenfields

Sessions

Whatarewrapperclasses?

InJavawehaveclassesforeachprimitivedatatypes.Theseclassesarecalledaswrapperclass.Forexample,Integer,Character,Double

etc.

Whatarecheckedexceptions?

ThereareexceptionsthatareforcedtocatchbyJavacompiler,e.gIOException.Thoseexceptionsarecalledcheckedexceptions.

WhatistheLocaleclass?

Localeclassisaclassthatconvertstheprogramoutputtoaparticulargeographic,political,orculturalregion

IsmainakeywordinJava?

No,mainisnotakeywordinJava.

WhatisthemostimportantfeatureofJava?

PlatformindependencymakesJavaapremiumlanguage.

WhatisaJVM?

JVMisJavaVirtualMachinewhichisaruntimeenvironmentforthecompiledjavaclassfiles.

DoesJavasupportmultipleinheritances?

No,Javadoesn'tsupportmultipleinheritances.

Whatisthebaseclassofallclasses?

java.lang.Object

Canaclassbedeclaredasprotected?

Aclasscan'tbedeclaredasprotected.Onlymethodscanbedeclaredasprotected.

2/23/2015

700Javainterviewquestionsandanswers­JavaFAQPDF

Cananabstractclassbedeclaredfinal?

No,sinceitisobviousthatanabstractclasswithoutbeinginheritedisofnouse.

Javainterviewquestionsandanswers­April22,2011

Canwedeclareavariableasabstract?

Variablescan'tbedeclaredasabstract.Onlyclassesandmethodscanbedeclaredasabstract.

DefineMarkerInterface.

AnInterfacewhichdoesn'thaveanydeclarationinsidebutstillenforcesamechanism.

Whatisanabstractmethod?

Anabstractmethodisamethodwhoseimplementationisdeferredtoasubclass.

Whencananobjectreferencebecasttoaninterfacereference?

Anobjectreferenceiscasttoaninterfacereferencewhentheobjectimplementsthereferencedinterface.

Whichclassisextendedbyallotherclasses?

TheObjectclassisextendedbyallotherclasses.

Whatisthereturntypeofaprogram'smain()method?

void.

WhataretheeightprimitiveJavatypes?

Theeightprimitivetypesarebyte,char,short,int,long,float,double,andboolean.

Differencebetweenapublicandanon­publicclass.

Apublicclassmaybeaccessedoutsideofitspackage.Anon­publicclassmaynotbeaccessedoutsideofitspackage.

WhichJavaoperatorisrightassociative?

The=operatorisrightassociative.

Whatisatransientvariable?

Transientvariableisavariablethatmaynotbeserialized.

1|2|3|4|5|6|7|8|9|10|11|12|13|14|15

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

Bookmarkto:

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

Оценить