Java - Interview Questions and Answers for 'Java keywords' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Java keywords' - 24 question(s) found - Order By Newest

 Q1. Which of the following combination of keywords is illegal in Java ?

a. static and transient
b. transient and final
c. static and synchronized
d. abstract and final
Core Java
Anonymous
Ans. abstract and final

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java keywords     VirtusaPolaris  IVTL InfoView Technologies      basic


 Q2. Can we access instance variables within static methods ?Core Java
Anonymous
Ans. Yes.we cannot access them directly but we can access them using object reference.Static methods belong to a class and not objects whereas non static members are tied to an instance. Accessing instance variables without the instance handler would mean an ambiguity regarding which instance the method is referring to and hence its prohibited.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   static   static methods   java keywords     Oracle


Advanced level question usually asked to senior developers , leads and architects.
 Q3. How does volatile affect code optimization by compiler?Core Java
Admin
info@buggybread.com
Ans. Volatile is an instruction that the variables can be accessed by multiple threads and hence shouldn't be cached. As volatile variables are never cached and hence their retrieval cannot be optimized.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java keywords   volatile   synchronization   compiler optimization   variable caching   architecture     Embedded security  Driver engineer  Sokrati      expert


Frequently asked question for intermediate developers.
  Q4. What is Volatile keyword used for ?Core Java
Anonymous
Ans. Volatile is a declaration that a variable can be accessed by multiple threads and hence shouldnt be cached.

  Sample Code for volatile

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   synchronization   volatile   java keywords     ABC Ltd   Ciena  Xchanging  Square  Infoview Technologies  HCL Technologies  EPAM  GrubHub  TeleMessage  TRUSTe  Informatica  Square  Medidata Solutions  Yellow Pages  eQ Technologic  Sutra Analytics  CustomerXPs  Globant  BB Holdings  Rakuten  Booking.com  BlackRock  Qualcomm  LSI Corporation  ARM Holdings  SpaceX  Toshiba  Peapod  Amadeus  Apptio  Tivo  EchoStar  HomeAway  Syscom Technologies  Aversan  Symantec  Samsung India  Axtria  Qualcomm  CGI Group      intermediate        frequent

Try 1 Question(s) Test


 Q5. What is the use of Transient Keyword ?Core Java
Anonymous
Ans. It in Java is used to indicate that a field should not be serialized.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   serialization   transient   java keywords     Cognizant (CTS)  The Advisory Board Company      intermediate        frequent

Try 2 Question(s) Test


 Q6. What is a Final Method ?Core Java
Anonymous
Ans. A Method that cannot be overriden in the sub class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   java keywords   final   final method   overriding   basic interview question      basic        frequent

Try 1 Question(s) Test


Very Frequently asked.Favorite question in Walk in drive for many Indian service companies.
 Q7. What is a Final Class ?
Anonymous
Ans. A Class that cannot be sub classed.

  Sample Code for final class

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   final   final class   java keyword   basic interview question     HCL Technologies  Tata Consultancy (TCS)  Infosys      basic        frequent


 Q8. Can we override static methods ? Why ?Core Java
Anonymous
Ans. No.

Static methods belong to the class and not the objects. They belong to the class and hence doesn't fit properly for the polymorphic behavior.

A static method is not associated with any instance of a class so the concept of overriding for runtime polymorphism using static methods is not applicable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   static   static methods   java keywords   yes-no      intermediate        frequent


 Q9. What is "super" used for ?
Anonymous
Ans. Used to access members of the base class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   java keywords   super   basic interview question      basic        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. What is "this" keyword used for ?
Anonymous
Ans. Used to represent an instance of the class in which it appears.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   java keywords   this   basic interview question      basic        frequent


 Q11. What is "Import" used for ?Core Java
Anonymous
Ans. Enables the programmer to abbreviate the names of classes defined in a package.

  Sample Code for import

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   import   java keyword


 Q12. What is a Static import ?Core Java
Anonymous
Ans. By static import , we can access the static members of a class directly without prefixing it with the class name.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java5   static import   static   java keyword   static import     Infosys  Weather Channel  Tata Consultancy (TCS)  ePace Technologies      basic        frequent


 Q13. Which of the following keyword is not permitted for outer class ?

a. public
b. abstract
c. final
d. protected
Anonymous
Ans. protected

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java keywords


 Q14. Explain the use of "Native" keyword ?Core Java
Anonymous
Ans. Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   native   java keywords     Teradata


 Q15. In majority of the situations it won't make much sense whether you append this with the instance method call.Can you tell a situation wherein this keyword would make sense in a instance method ? Core Java
admin
info@buggybread.com
Ans. Within instance method of the parent class that has other multiple methods that have been overridden by the derived classes.

In such case a simple method call from the common method will always be made to the method definition in the parent class. But If we use this.methodCall , this will be polymorphic and will be made to the respective derived object overriding method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   this keyword   java keywords


 Q16. Which of the following is not true for final variables ?

a. They cannot be changed after initialization
b. They can be initialized within static method
c. They can be declared and initialized together at the same place
d. They can be initialized within constructor
Anonymous
Ans. They can be initialized within static method

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   final   final variable   java keywords


 Q17. Which of the following is false for final ?

a. Final methods cannot be overriden
b. Final methods cannot be overloaded
c. Final classes cannot be subclassed
d. Final class cannot be abstract
Anonymous
Ans. Final methods cannot be overloaded

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   final   java keyword


 Q18. Why can't we declare a class abstract as well as final ?Core Java

Ans. Abstract means that the class is only meant to be subclassed whereas final means that it cannot be subclassed so both concepts - abstract and final are actually mutually exclusive and hence not permitted together.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     abstract   final   java keywords     VirtusaPolaris


 Q19. Name some of the Java Keywords ?Core Java2017-01-07 16:54:09

Ans. Static , Final , Synchronized, private , public , protected, volatile, transient, super, this,import , abstract,native,default (effective java 8), new

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java keywords        frequent



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. Which are the reserved words in Java ?Core Java2017-05-31 16:52:35

Ans. All Keywords , modifiers ( public , static , final etc ) as well as non modifier keywords ( for, if,switch etc ) are reserved words in java and hence cannot be used as identifiers. Along with keywords , there are few literals that have predefined meaning and hence cannot be used as identifiers, these are true , false and null.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java keywords  java reserved words


 Q21. The use of volatile keyword facilitates ..Core Java
a. Making Use of Cache for better Performance
b. Avoiding use of Cache
c. Making use of Backward as well as Forward Cache
d. Keeping only one copy of variable in Cache

Ans.b. Avoiding use of Cache

 Q22. Which of following keyword is not allowed for Outer Class ?Core Java
a. public
b. private
c. abstract
d. final

Ans.b. private

 Q23. Which of the following keyword restrict the class from being extended ?Core Java
a. Private
b. Abstract
c. Final
d. Static

Ans.c. Final

 Q24. Which of the following keyword restrict the class from being instantiated ?Core Java
a. Private
b. Abstract
c. Final
d. Static

Ans.b. Abstract



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: