Wase Solution | Object Oriented Programming Solved

Wase Solution | Object Oriented Programming Solved

Birla Institute of Technology And Science, Pilani Distance Learning Programmes Division BITS-WIPRO Collaborative Programme : MS Software Engineering Second Semester 2007 — 2008 Answer Key
SEWPZC432 Object Oriented Programming Closed Book 
PART I – (20 x 0.5 mark = 10 marks) Answer very briefly in a word, phrase or sentence.
1. Does state of an object always affect its behavior? Validate your claim.
Yes. Consider the computer as an object. It reacts to keyboard presses differently depending on its current state – being on or off.
2. Explain the Encapsulation principle.
Data hiding. Grouping or encapsulating the data and the operations on the-data into a single abstraction called Class and providing stable APIs to the Class users.
3. main, public, private are keywords in Java. True / False.
False. ‘main’ is not a keyword.
4. Differentiate between ‘Array is empty’ and ‘Array is Null’. In Java, an array of ‘Zero’ elements is termed as Empty, while an array which is not instantiated (with new) is ‘null’.
We can assign an array a null value but we cannot create an empty array by using a blank Index. Int[] array = null: // legal int[l array = new int[]; /1 illegal
5. What are the means provided in Java to compare the state and identity of two String objects?
State – equals() method: Identity `==’ operator.
String a = new String(“WASE”);
String b = new String(“CLASS”);
if (a.equals(b)) {
// State is same for both a and b. but not identity.
}
6. List the 8 primitive types in Java.
byte, short, int, long, boolean. float, double, char
7. List out the advantages of Javadoc.
Automat(g)ically generates HTML formatted documentation from developer comments in Java source code.
8. The Julian clay number for May 23, 1968 12 PM is 2,440,000. The Julian day number of May 23, 1971, 12 PM is 2441095
1 Julian day number 4 1 clay. 1968 to 1971 no leap years -> 3 years -> 365 x 3 = 1.095
9. What are the methods provided in the Icon interface in Java.

  •  int geticonHeight() – Returns the icon’s height.
  • int getlconWidth() – Returns the icon’s width.
  • void painticon(Component c, Graphics g, int x, int y) – Draw at specified location.

10. The _final keyword is used to declare variables that do no change state in Java.
11. In Java, Static fields in a class cannot be accessed from non-static methods of the same class. True/False
False. Static fields or members can be accessed from both static and non-static methods of the same class.
12. Java supports operator overloading albeit in a limited fashion. True / False.
False. Operator Overloading is not supported in Java.
13. Identification of classes is carried out in
Design phase of the project.
14. A method that affects the state of an object is termed as
Mutator
15. State the simple thumb rule to identify classes in a project.
Look for Nouns in the project functional specifications.
16. The “is-a” relationship between classes is termed as
Inheritance in Object Oriented Design.
17. State the Law of Demeter.
Principle of Least Knowledge. – “Talk only to your immediate/close friends” Class A calling class B need not know about B’s internal structure.
18. When is the code in the ‘finally’ block executed?
Always ! As below: try { // Statements in which exceptions might be thrown
} catch(exception)( // Statements that execute in the event of an exception finally { // Statements that execute afterward either way }