Monday, June 15, 2015

core java interview question part7

10:02 AM

core java interview question part7



Q1 - Three keywords are used in Java to specify access control. What are they?
A - The three keywords used to specify access control in Java are public, private, and protected.
Q2 - In Java, special access privileges are afforded to other members of the same package: True or False? If false, explain your answer.
A - True. In Java, special access privileges are afforded to other members of the same package.
Q3 - In Java, class variables are often used with the __________ keyword to create variables that act like constants.
A - The final keyword.
Q4 - In Java, the ___________ keyword is used to declare a class variable.
A - The static keyword.
Q5 - In Java, the ___________ keyword is used to declare a class method.
A - The static keyword.
Q6 - When you include a method in a Java class definition without use of static keyword, this will  result in objects of that class containing an instance method: True or False? If false, explain why.
A 7- True.
Q8 - Normally each object contains its own copy of each instance method: True or False?
A - False, multiple copies of the method do not normally exist in memory.
Q9- When you invoke an instance method using a specific object, if that method refers to instance variables of the class, that method is caused to refer to the specific instance variables of the specific object for which it was invoked: True or False? If false, explain why.
A - True.
Q10 - Instance methods are invoked in Java using the name of the object, the colon, and the name of  the method as shown below: True or False? If false, explain why.
     myObject:myInstanceMethod( )
A - False. Use the period or dot operator, not the colon.
Q11 - Instance methods have access to both instance variables and class variables in Java: True or False. If false, explain why.
A - True.
Q12 - Class methods have access to both instance variables and class variables in Java: True or False. If false, explain why.
A - False. Class method can only access other class members.
Q13 - What are the two most significant characteristics of class methods?
A - 1. Class methods can only access other class members. 2. Class methods can be accessed using only the name of the class. An object of the class is not required to access class methods.
Q14 - In Java, a class method can be invoked using the name of the class, the colon, and the name of  the method as shown below: True or False? If false, explain why.
     MyClass:myClassMethod()
A - False. You must use the period or dot operator, not the colon.
Q15 - What is meant by overloaded methods?
A - The term overloaded methods means that two or more methods may have the same name so long as they have different argument lists.
Q16 - If you overload a method name, the compiler determines at run time, on the basis of the arguments provided to the invocation of the method, which version of the method to call in that instance: True or False? If false, explain why.
A - False. The determination is made at compile time.
Q16 - A constructor is a special method which is used to construct an object. A constructor always has the same name as the class in which it is defined, and has no return type specified. True or False? If false, explain why.
A - True.
Q17 - Constructors may be overloaded, so a single class may have more than one constructor, all of which have the same name, but different argument lists: True or False. If false, explain why.
A - True
Q18 - What is the purpose of a parameterized constructor?
A - The purpose of a parameterized constructor is to initialize the instance variables of an object when the object is instantiated.
Q 19 - The same set of instance variables can often be initialized in more than one way using overloaded constructors: True or False? If false, explain why.
A - True.
Q20  - It is not necessary to provide a constructor in Java. True or False? If false, explain why.
A - True. .
Q 21 You can think of the default constructor as a constructor which doesn't take any parameters: True or False? If false, explain why.
A - True.
Q 22- In Java, if you provide any constructors, the default constructor is no longer provided automatically: True or False? If false, explain why.
A - True.
Q 23- In Java, if you need both a parameterized constructor and a constructor which doesn't take parameters (often called a default constructor), you must provide them both: True or False? If false,explain why.
A - True.

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 comments:

Post a Comment

 

© 2013 Java Tutorials. All rights resevered. Designed by Templateism

Back To Top