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

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Keyword' - 45 question(s) found - Order By Rating

next 30
 Q1. What is the Main Advantage of the native Key Word?Core Java
 This question is still unanswered. Can you please provide an answer.


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

   Like         Discuss         Correct / Improve     native keyword


 Q2. Can we declare an Interface with abstract keyword ? Core Java
Ans. Yes

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

   Like         Discuss         Correct / Improve     abstract keyword


 Q3. Are final methods faster than regular instance methods ?Core Java
Ans. Yes. As they cannot be overridden , there is no use of virtual table concept which is used for dynamic binding resolution.

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

   Like         Discuss         Correct / Improve     final methods   final keyword      expert


 Q4. Why Java has final class ?Core Java
 This question was recently asked at 'Avis'.This question is still unanswered. Can you please provide an answer.


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

   Like         Discuss         Correct / Improve     final class   final keyword     Asked in 1 Companies      basic


 Q5. How different is it when final applied to variables and object references ? Core Java
Ans. final when assigned to object references doesn't make them immutable. It means that the references cannot be de-referenced.

final when applied to variables means that the value cannot be changed.

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

   Like         Discuss         Correct / Improve     final keyword  final variable


 Q6. When we say final x = 10, is the reference final or the value ?Core Java
Ans. final keyword have meaning only to referenced and not the value. It means that the specified reference cannot be dereferenced. It doesn't control the value assigned to the memory that's being referenced. This is the reason that final object references doesn't mean that the object is immutable but means that the reference cannot be changed to point to new object.

In case of primitive types too, when we assign a reference to another, values are passed and not the object reference, and hence a new placeholder is created in memory with the same value. That is why final to that context means that you cannot change the assigned memory and there is no way we can have that memory place have another value.

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

   Like         Discuss         Correct / Improve     final keyword  final variables  references


 Q7. What is the use of final keyword ?Core Java
Ans. final keyword is a modifier that means differently when applied to variables, methods and classes.

1. Final variable cannot be changed once initialized
2. Final method cannot be overridden
3. Final class cannot be sub classed

  Sample Code for final variable

  Sample Code for final method

  Sample Code for final class

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

   Like         Discuss         Correct / Improve     final  final keyword     Asked in 1 Companies      Basic        frequent


 Q8. Which are the reserved words in Java ?Core Java
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


 Q9. Why is goto not used in Java?Core Java
Ans. Goto statement results in unstructured jumps in control from one code location to another and hence makes the code very difficult
to read , maintain and debug. Moreover Goto can always be replaced using other statements like break / continue and hence results in structured movement of programming control.

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

   Like         Discuss         Correct / Improve     goto  keywords


 Q10. What is the difference between keywords, identifiers and literals in java ?Core Java
Ans. Keywords are the reserved words that have a pre defined meaning for the compiler and hence are restricted to be used as identifiers.

Identifiers are the name assigned to different programming constructs like classes, interfaces, methods , variables etc.

Literals are the values that are assigned to Identifiers.

For example

int count = 0;

in the above statement "int" is a keyword, "count" is an identifier and "0" is a literal

  Sample Code for keywords

  Sample Code for identifiers

  Sample Code for literals

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

   Like         Discuss         Correct / Improve     keywords  literals  identifiers


 Q11. Can we use true and false as identifiers in java ? Are they keywords in Java ?Core Java
Ans. true and false are literals in java. No we cannot use them as identifiers.

  Sample Code for literal

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

   Like         Discuss         Correct / Improve     identifiers  keywords  literals


 Q12. Can we use java keywords as identifiers ?Core Java
Ans. No, keyword has pre defined meaning for compiler and hence cannot be used as identifiers.

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

   Like         Discuss         Correct / Improve     keywords  identifier


 Q13. What is a difference between Identifier and keyword ?Core Java
Ans. Keyword is a reserved word that has a pre defined meaning for the compiler and hence cannot be used as an identifier, for example - final, private , for etc.

Identifier is the name given by the programmer to a programming construct, for example - class and method names etc.

java Keywords cannot be used as an identifier in java.

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

   Like         Discuss         Correct / Improve     identifier  keyword


 Q14. Which of the following applies to "private"?

It is a keyword
It is a modifier
It is an access modifier
Core Java
Ans. Yes, all of them applies to private keyword. It is an access modifier.

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

   Like         Discuss         Correct / Improve     keyword  modifier


 Q15. Which of the following applies to Final ?

It is a keyword
It is a modifier
It is an access modifier
Core Java
Ans. It is a keyword and a modifier but not an access modifier.

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

   Like         Discuss         Correct / Improve     keyword  modifier


 Q16. What is the difference between a keyword and a modifier ?Core Java
Ans. Keywords are the reserved words that have a pre defined meaning for a compiler whereas modifiers are the type of keywords that modifies the state or definition of a programming construct.

for, while are keywords but not modifiers.
private , public , final , abstract etc are keywords as well as modifiers.

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

   Like         Discuss         Correct / Improve     keyword  modifier


 Q17. Is exit a keyword in Java ?Core Java
Ans. No exit is a method to exit execution of a program.

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

   Like         Discuss         Correct / Improve     exit  keywords  exit a program     Asked in 1 Companies


 Q18. Is delete a keyword in Java ?Core Java
Ans. No, delete is not a keyword in Java. Destruction of objects is taken care by Java Garbage Collection mechanism.

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

   Like         Discuss         Correct / Improve     delete  keywords     Asked in 1 Companies


 Q19. What is the use of static keyword in Java ?Core Java
Ans. static keyword is used to specify that the respective programming construct ( method , variable ) belongs to the class and not to its instance and is supposed to be shared by all instances of the class.

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

   Like         Discuss         Correct / Improve     static keyword     Asked in 1 Companies      basic        frequent


 Q20. Name some of the Java Keywords ?Core Java
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


 Q21. Is New Keyword a method Name ?Core Java
Ans. No, Its an Operator.

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

   Like         Discuss         Correct / Improve     new keyword  operator


 Q22. Does compiler treats it differently if we don't prefix this to the member element and its implicit as its the only variable available with that name ?
Ans. It makes no difference whether we add this to the variable or not. The only use of this is in the cases where there are multiple variables with the same name and we want to distinguish between the member variable and local variable. In case this is not added ,this is automatically added by the compiler in the byte code.

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

   Like         Discuss         Correct / Improve     this keyword  member elements  member variables


Frequently asked question for intermediate developers. Frequently asked in HCL Technologies and EPAM.
  Q23. What is Volatile keyword used for ?Core Java
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     Asked in 42 Companies      intermediate        frequent

Try 1 Question(s) Test


  Q24. What is the use of Transient Keyword ?Core Java
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     Asked in 39 Companies      intermediate        frequent

Try 2 Question(s) Test


 Q25. What is a Final Method ?Core Java
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.
 Q26. What is a Final Class ?
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     Asked in 3 Companies      basic        frequent


 Q27. Can we override static methods ? Why ?Core Java
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


 Q28. Can we access instance variables within static methods ?Core Java
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     Asked in 1 Companies


 Q29. Explain the use of "Native" keyword ?Core Java
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     Asked in 1 Companies


 Q30. What is "super" used for ?
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     Asked in 2 Companies      basic        frequent


next 30

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: