{"id":141,"date":"2020-04-03T09:00:41","date_gmt":"2020-04-03T09:00:41","guid":{"rendered":"https:\/\/temp.ashkerala.com\/?p=141"},"modified":"2020-04-03T09:00:41","modified_gmt":"2020-04-03T09:00:41","slug":"java-terminology","status":"publish","type":"post","link":"https:\/\/temp.ashkerala.com\/?p=141","title":{"rendered":"Java Terminology"},"content":{"rendered":"<p><strong>Introduction to Classes and Methods<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) Which is used to get the value of the instance variables?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Dot notation.<\/p>\n<p> \u00a0\u00a0\u00a0 2) The new operator creates a single instance named class and returns a reference to that object.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 3) A class is a template for multiple objects with similar features.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 4) What is mean by garbage collection?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: When an object is no longer referred to by any variable, Java automatically reclaims memory used by that object. This is known as garbage collection.<\/p>\n<p> \u00a0\u00a0\u00a0 5) What are methods and how are they defined?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Methods are functions that operate on instances of classes in which they are defined.Objects can communicate with each other using methods and can call methods in other classes.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method&#8217;s signature is a combination of the first three parts mentioned above.<\/p>\n<p> \u00a0\u00a0\u00a0 6) What is calling method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Calling methods are similar to calling or referring to an instance variable. These methods are accessed using dot notation.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ex: obj.methodname(param1,param2)<\/p>\n<p> \u00a0\u00a0\u00a0 7) Which method is used to determine the class of an object?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: getClass( ) method can be used to find out what class the belongs to. This class is defined in the object class and is available to all objects.<\/p>\n<p> \u00a0\u00a0\u00a0 8) All the classes in java.lang package are automatically imported when a program is compiled.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 9) How can class be imported to a program?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: To import a class, the import keyword should be used as shown.;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 import classname;<\/p>\n<p> \u00a0\u00a0\u00a0 10) How can class be imported from a package to a program?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: import java . packagename . classname (or) import java.package name.*;<\/p>\n<p> \u00a0\u00a0\u00a0 11) What is a constructor?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: A constructor is a special kind of method that determines how an object is initialized when created.<\/p>\n<p> \u00a0\u00a0\u00a0 12) Which keyword is used to create an instance of a class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: new.<\/p>\n<p> \u00a0\u00a0\u00a0 13) Which method is used to garbage collect an object?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: finalize ().<\/p>\n<p> \u00a0\u00a0\u00a0 14) Constructors can be overloaded like regular methods.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 15) What is casting?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Casting is bused to convert the value of one type to another.<\/p>\n<p> \u00a0\u00a0\u00a0 16) Casting between primitive types allows conversion of one primitive type to another.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 17) Casting occurs commonly between numeric types.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 18) Boolean values can be cast into any other primitive type.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b.<\/p>\n<p> \u00a0\u00a0\u00a0 19) Casting does not affect the original object or value.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 20) Which cast must be used to convert a larger value into a smaller one?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Explicit cast.<\/p>\n<p> \u00a0\u00a0\u00a0 21) Which cast must be used to cast an object to another class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Specific cast.<\/p>\n<p> \u00a0\u00a0\u00a0 22) Which of the following features are common to both Java &amp; C++?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 A.The class declaration<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.The access modifiers<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.The encapsulation of data &amp; methods with in objects<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.The use of pointers<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b,c.<\/p>\n<p> \u00a0\u00a0\u00a0 23) Which of the following statements accurately describe the use of access modifiers within a class definition?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.They can be applied to both data &amp; methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.They must precede a class&#8217;s data variables or methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.They can follow a class&#8217;s data variables or methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.They can appear in any order<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 e.They must be applied to data variables first and then to methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b,d.<\/p>\n<p> \u00a0\u00a0\u00a0 24) Suppose a given instance variable has been declared private. Can this instance variable be manipulated by methods out side its class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.yes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.no<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b.<\/p>\n<p> \u00a0\u00a0\u00a0 25) Which of the following statements can be used to describe a public method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.It is accessible to all other classes in the hierarchy<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.It is accessablde only to subclasses of its parent class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.It represents the public interface of its class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.The only way to gain access to this method is by calling one of the public class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,c.<\/p>\n<p> \u00a0\u00a0\u00a0 26) Which of the following types of class members can be part of the internal part of a class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.Public instance variables<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.Private instance variables<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.Public methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.Private methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b,d.<\/p>\n<p> \u00a0\u00a0\u00a0 27) You would use the ____ operator to create a single instance of a named class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.new<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.dot<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 28) Which of the following statements correctly describes the relation between an object and the instance variable it stores?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.Each new object has its own distinctive set of instance variables<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.Each object has a copy of the instance variables of its class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.the instance variable of each object are seperate from the variables of other objects<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.The instance variables of each object are stored together with the variables of other objects<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b,c.<\/p>\n<p> \u00a0\u00a0\u00a0 29) If no input parameters are specified in a method declaration then the declaration will include __.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.an empty set of parantheses<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.the term void<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 30) What are the functions of the dot(.) operator?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.It enables you to access instance variables of any objects within a class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.It enables you to store values in instance variables of an object<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.It is used to call object methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d.It is to create a new object<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b,c.<\/p>\n<p> \u00a0\u00a0\u00a0 31) Which of the following can be referenced by this variable?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.The instance variables of a class only<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.The methods of a class only<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.The instance variables and methods of a class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: c.<\/p>\n<p> \u00a0\u00a0\u00a0 32) The this reference is used in conjunction with ___methods.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.static<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.non-static<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b.<\/p>\n<p> \u00a0\u00a0\u00a0 33) Which of the following operators are used in conjunction with the this and super references?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.The new operator<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.The instanceof operator<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.The dot operator<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: c.<\/p>\n<p> \u00a0\u00a0\u00a0 34) A constructor is automatically called when an object is instantiated<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 35) When may a constructor be called without specifying arguments?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. When the default constructor is not called<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. When the name of the constructor differs from that of the class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c. When there are no constructors for the class<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: c.<\/p>\n<p> \u00a0\u00a0\u00a0 36) Each class in java can have a finalizer method<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 37) When an object is referenced, does this mean that it has been identified by the finalizer method for garbage collection?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.yes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.no<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b.<\/p>\n<p> \u00a0\u00a0\u00a0 38) Because finalize () belongs to the java.lang.Object class, it is present in all ___.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.objects<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.classes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.methods<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b.<\/p>\n<p> \u00a0\u00a0\u00a0 39) Identify the true statements about finalization.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.A class may have only one finalize method<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.Finalizers are mostly used with simple classes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c.Finalizer overloading is not allowed<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,c.<\/p>\n<p> \u00a0\u00a0\u00a0 40) When you write finalize() method for your class, you are overriding a finalizer inherited from a super class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 41) Java memory management mechanism garbage collects objects which are no longer referenced<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 42) are objects referenced by a variable candidates for garbage collection when the variable goes out of scope?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a yes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. no<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 43) Java&#8217;s garbage collector runs as a ___ priority thread waiting for __priority threads to relinquish the processor.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.high<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.low<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b.<\/p>\n<p> \u00a0\u00a0\u00a0 44) The garbage collector will run immediately when the system is out of memory<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a.<\/p>\n<p> \u00a0\u00a0\u00a0 45) You can explicitly drop a object reference by setting the value of a variable whose data type is a reference type to ___<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: null<\/p>\n<p> \u00a0\u00a0\u00a0 46) When might your program wish to run the garbage collecter?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. before it enters a compute-intense section of code<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. before it enters a memory-intense section of code<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c. before objects are finalized<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d. when it knows there will be some idle time<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a,b,d<\/p>\n<p> \u00a0\u00a0\u00a0 47) For externalizable objects the class is solely responsible for the external format of its contents<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a<\/p>\n<p> \u00a0\u00a0\u00a0 48) When an object is stored, are all of the objects that are reachable from that object stored as well?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.true<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a<\/p>\n<p> \u00a0\u00a0\u00a0 49) The default__ of objects protects private and trancient data, and supports the __ of the classes<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a.evolution<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b.encoding<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: b,a.<\/p>\n<p> \u00a0\u00a0\u00a0 50) Which are keywords in Java?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a) NULL<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) sizeof<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c) friend<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d) extends<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 e) synchronized<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : d and e<\/p>\n<p> \u00a0\u00a0\u00a0 51) When must the main class and the file name coincide?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans :When class is declared public.<\/p>\n<p> \u00a0\u00a0\u00a0 52) What are different modifiers?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public, private, protected, default, static, trancient, volatile, final, abstract.<\/p>\n<p> \u00a0\u00a0\u00a0 53) What are access modifiers?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public, private, protected, default.<\/p>\n<p> \u00a0\u00a0\u00a0 54) What is meant by &#8220;Passing by value&#8221; and &#8221; Passing by reference&#8221;?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : objects \u0393\u00c7\u00f4 pass by referrence<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Methods &#8211; pass by value<\/p>\n<p> \u00a0\u00a0\u00a0 55) Is a class a subclass of itself?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : A class is a subclass itself.<\/p>\n<p> \u00a0\u00a0\u00a0 56) What modifiers may be used with top-level class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public, abstract, final.<\/p>\n<p> \u00a0\u00a0\u00a0 57) What is an example of polymorphism?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Inner class<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Anonymous classes<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method overloading<br \/> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Method overriding<\/p>\n<p><strong>Packages and interface<\/strong><\/p>\n<p> \u00a0\u00a0\u00a0 1) What are packages ? what is use of packages ?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans :The package statement defines a name space in which classes are stored.If you omit the package, the classes are put into the default package.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Signature&#8230; package pkg;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Use: * It specifies to which package the classes defined in a file belongs to. * Package is both naming and a visibility control mechanism.<\/p>\n<p> \u00a0\u00a0\u00a0 2) What is difference between importing &#8220;java.applet.Applet&#8221; and &#8220;java.applet.*;&#8221; ?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans :&#8221;java.applet.Applet&#8221; will import only the class Applet from the package java.applet<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Where as &#8220;java.applet.*&#8221; will import all the classes from java.applet package.<\/p>\n<p> \u00a0\u00a0\u00a0 3) What do you understand by package access specifier?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public: Anything declared as public can be accessed from anywhere<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 private: Anything declared in the private can\u0393\u00c7\u00d6t be seen outside of its class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 default: It is visible to subclasses as well as to other classes in the same package.<\/p>\n<p> \u00a0\u00a0\u00a0 4) What is interface? What is use of interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : It is similar to class which may contain method\u0393\u00c7\u00d6s signature only but not bodies.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Methods declared in interface are abstract methods. We can implement many interfaces on a class which support the multiple inheritance.<\/p>\n<p> \u00a0\u00a0\u00a0 5) Is it is necessary to implement all methods in an interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Yes. All the methods have to be implemented.<\/p>\n<p> \u00a0\u00a0\u00a0 6) Which is the default access modifier for an interface method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public.<\/p>\n<p> \u00a0\u00a0\u00a0 7) Can we define a variable in an interface ?and what type it should be ?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Yes we can define a variable in an interface. They are implicitly final and static.<\/p>\n<p> \u00a0\u00a0\u00a0 8) What is difference between interface and an abstract class?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 In Interface we need not use the keyword abstract for the methods.<\/p>\n<p> \u00a0\u00a0\u00a0 9) By default, all program import the java.lang package.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True\/False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : True<\/p>\n<p> \u00a0\u00a0\u00a0 10) Java compiler stores the .class files in the path specified in CLASSPATH<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 environmental variable.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True\/False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : False<\/p>\n<p> \u00a0\u00a0\u00a0 11) User-defined package can also be imported just like the standard packages.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True\/False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : True<\/p>\n<p> \u00a0\u00a0\u00a0 12) When a program does not want to handle exception, the ______class is used.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Throws<\/p>\n<p> \u00a0\u00a0\u00a0 13) The main subclass of the Exception class is _______ class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : RuntimeException<\/p>\n<p> \u00a0\u00a0\u00a0 14) Only subclasses of ______class may be caught or thrown.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Throwable<\/p>\n<p> \u00a0\u00a0\u00a0 15) Any user-defined exception class is a subclass of the _____ class.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Exception<\/p>\n<p> \u00a0\u00a0\u00a0 16) The catch clause of the user-defined exception class should ______ its Base class catch clause.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Exception<\/p>\n<p> \u00a0\u00a0\u00a0 17) A _______ is used to separate the hierarchy of the class while declaring an Import statement.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Package<\/p>\n<p> \u00a0\u00a0\u00a0 18) All standard classes of Java are included within a package called _____.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : java.lang<\/p>\n<p> \u00a0\u00a0\u00a0 19) All the classes in a package can be simultaneously imported using ____.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : *<\/p>\n<p> \u00a0\u00a0\u00a0 20) Can you define a variable inside an Interface. If no, why? If yes, how?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans.: YES. final and static<\/p>\n<p> \u00a0\u00a0\u00a0 21) How many concrete classes can you have inside an interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans.: None<\/p>\n<p> \u00a0\u00a0\u00a0 22) Can you extend an interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans.: Yes<\/p>\n<p> \u00a0\u00a0\u00a0 23) Is it necessary to implement all the methods of an interface while implementing the interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans.: No<\/p>\n<p> \u00a0\u00a0\u00a0 24) If you do not implement all the methods of an interface while implementing , what specifier should you use for the class ?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans.: abstract<\/p>\n<p> \u00a0\u00a0\u00a0 25) How do you achieve multiple inheritance in Java?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Using interfaces.<\/p>\n<p> \u00a0\u00a0\u00a0 26) How to declare an interface example?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : access class classname implements interface.<\/p>\n<p> \u00a0\u00a0\u00a0 27) Can you achieve multiple interface through interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b) false<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : a.<\/p>\n<p> \u00a0\u00a0\u00a0 28) Can variables be declared in an interface ? If so, what are the modifiers?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Yes. final and static are the modifiers can be declared in an interface.<\/p>\n<p> \u00a0\u00a0\u00a0 29) What are the possible access modifiers when implementing interface methods?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : public.<\/p>\n<p> \u00a0\u00a0\u00a0 30) Can anonymous classes be implemented an interface?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Yes.<\/p>\n<p> \u00a0\u00a0\u00a0 31) Interfaces can\u0393\u00c7\u00d6t be extended.<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : b.<\/p>\n<p> \u00a0\u00a0\u00a0 32) Name interfaces without a method?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Serializable, Cloneble &amp; Remote.<\/p>\n<p> \u00a0\u00a0\u00a0 33) Is it possible to use few methods of an interface in a class ? If so, how?<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans : Yes. Declare the class as abstract.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Classes and Methods \u00a0\u00a0\u00a0 1) Which is used to get the value of the instance variables? \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: Dot notation. \u00a0\u00a0\u00a0 2) The new operator creates a single instance named class and returns a reference to that object. \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a)True \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b)False \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Ans: a. \u00a0\u00a0\u00a0 3) A class is a template for&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-java-programming"],"_links":{"self":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":0,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}