OBJECT ORIENTED ROGRAMMING With Question And Answer Full

5,223 views

Published on

 Basics overview of programming paradigms
 Features of OOPS
 Classes
 Encapsulation
 Polymorphism
 Inheritance

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,223
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
151
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

OBJECT ORIENTED ROGRAMMING With Question And Answer Full

  1. 1. UNIT 1 OBJECT ORIENTED ROGRAMMING UNIT STRUCTURE       Basics overview of programming paradigms Features of OOPS Classes Encapsulation Polymorphism Inheritance LEARNING OBJECTIVES After going through this unit, you should be able to:  find the importance of OO approach;  define the basic concepts of OO approach;  differentiate between object and procedure-oriented approaches;  know about various OO languages;  describe the applications of OOP, and  Understand the benefits of OO approach. 1. Object oriented programming Java's origins go back to 1991, when Sun Microsystems began looking for ways to create platform-independent code to support consumer electronic products. After some initial efforts with C++, the Sun project team abandoned it and created its own language initially called Oak, later renamed Java. Oak first was used to create software for a personal, handheld remote control device, but when the project team lost a bid to develop a television settop box for Time-Warner, attention switched to the Web. The Sun project team then built a Web browser, originally called WebRunner and then renamed HotJava, in the Java programming language. The rest, as they say, is history: Sun formally announced Java and HotJava at the SunWorld '95 conference in San Francisco on May 23, 1995.
  2. 2. Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. The programming challenge was seen as how to write the logic, not how to define the data. Objectoriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on a computer desktop (such as buttons and scroll bars). Real world objects The first step in OOP is to identify all the objects the programmer wants to manipulate and how they relate to each other, an exercise often known as data modeling. Once an object has been identified, it is generalized as a class of objects (think of Plato's concept of the "ideal" chair that stands for all chairs) which defines the kind of data it contains and any logic sequences that can manipulate it. Each distinct logic sequence is known as a method. Objects communicate with well-defined interfaces called messages.
  3. 3. The concepts and rules used in object-oriented programming provide these important benefits: a) The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding. b) Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption. c) The definition of a class is reuseable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks). d) The concept of data classes allows a programmer to create any new data type that is not already defined in the language itself. EVOLUTION OF OO METHODOLOGY Simula was the first object-oriented programming language. Java, Python, C++, Visual Basic .NET and Ruby are the most popular OOP languages today. The Java programming language is designed especially for use in distributed applications on corporate networks and the Internet. Ruby is used in many Web applications. Curl, Smalltalk, Delphi and Eiffel are also examples of object-oriented programming languages. Java is an object-oriented programming language based on C++ that allows small programs -- or "applets" -- to be embedded within an HTML document. When the user clicks on the appropriate part of the HTML page to retrieve it from a Web server, the applet is downloaded into the client workstation environment, where it begins executing. [Editor's note: Since this text was written, the definition of Java has expanded beyond Web-based applets; Sun expects the language to be used for all sorts of applications, and promises a Java operating system, Java microprocessors, and more -- and now refers to Java as a platform.
  4. 4. The relationship among Java programs (or "applets"), the Java-enabled browser, and the Web is illustrated in Figure. Users access a Web page and pull it down to their client. In this case, though, the Web page contains an additional HTML tag called "APP," which refers to a Java applet, and that applet can be located anywhere on the Web. If the user's Web browser is Javaenabled (for example, Sun's HotJava browser or Netscape's Navigator 2.0), then the applet is pulled down into the user's client computer and executed within the browser environment. Java is often described as a "cross-platform" programming language; it's also common to refer to Java programs as "architecture-neutral byte codes." It has to be this way, of course, because the Web server that delivers the Java applet to the Web client doesn't know what kind of hardware/software environment it's running on. And the developer who creates the Java applet doesn't want to worry about whether it will work correctly on OS/2, Windows, Unix, and MacOS. 1) The Java compiler, javac, which translates human-readable Java source code to architecture-neutral bytecodes. 2) The Java interpreter, which executes Java programs on the user's PC or workstation. 3) The C header and source file generator, javah and java_g. These are used to generate header files for C, as well as source files for making "methods" (roughly equivalent to procedures or subroutines in other languages) within Java. 4) The Java disassembler, javap, which prints out information about a class file (a file containing a Java applet). 5) The document generator, javadoc, which is capable of generating an HTML file from a Java source-code file. 6) The profiling tool, javaprof, which formats the performance data created if the programmer uses the -prof option in the Java interpreter to obtain statistics on run time and performance. Security and robust behavior Security and robustness are obviously important in the distributed environment represented by the Internet; if you download a Java applet from a Web server, for example, you really don't want it to run amok on your computer and delete all the files on your hard disk. This is not as farfetched as it might sound, because the incorporation of Java applets into Web pages means that you may be invoking computer programs written by people anywhere in the world, located anywhere on the Web. Indeed, once you begin using a Java-enabled browser, you're automatically at risk since you don't know at the moment you decide to retrieve a Web page (say,
  5. 5. by clicking on a hyperlink within an existing page being displayed on your computer) whether it will contain embedded Java applets. Sun has addressed this concern by imposing severe constraints on the Java programming language, as well as extensive run-time checking in the interpreter located inside the Javaenabled browser. The Java language, for example, forbids the use of address pointers and pointer arithmetic found in C and C++; this eliminates a large class of innocent errors that might otherwise plague the user of Java applets. In addition, the following steps have been taken to increase the level of security and robust behavior: 1) The Java run-time interpreter verifies that bytecodes (the compiled architecture-neutral form of Java applet that gets downloaded from the Web server into the user's machine) don't violate any language constructs -- which could happen if an altered Java compiler was used by a hacker. The verification logic checks to make sure that the Java applet doesn't access restricted memory, forge memory pointers, or access objects in a manner inconsistent with its definition. It also ensures that method (subroutine) calls include the correct number of arguments of the right type, and that there are no stack overflows. 2) During loading of the Java applet, the run-time interpreter verifies class names (a "class" is an entire Java applet) and access restrictions. 3) If a Java applet attempts to access a file for which it has no permission, a dialog box will pop up to allow the user to continue or stop the execution of the applet. 4) Future releases of Java are planned to have facilities for using public key encryption to verify the source and origin of the Java source code and its integrity after traveling through the network to reach the user's machine. 5) At run time, information about the origin of the Java applet can be used to decide what the applet is allowed to do. For example, a security mechanism can be used to determine whether the compiled Java byte codes originated from within an organization's security firewall or not. This makes it possible to set a security policy that restricts the use and execution of Java code that an organization doesn't know or trust.
  6. 6. This last point is crucial, for there are likely to be a number of attempts -- both innocent and malicious -- to circumvent the security mechanisms that Sun has built into the language. In its white paper on the Java language, Sun expresses the following optimistic statement about Java security: Java is designed to operate in distributed environments, which means that security is of paramount importance. With security features designed into the language and run-time system, Java lets you construct applications that can't be invaded from outside. In the networked environment, applications written in Java are secure from intrusion by unauthorized code attempting to get behind the scenes and create viruses or invade file systems. For the securityconscious organizations, though, the firewall protection mentioned above will be crucial -- at least in the short term. Basics overview of programming paradigms, The term paradigm describes a set of techniques, methods, theories and standards that together represent a way of thinking for problem solving. According to [Wegner, 1988], paradigms are “patterns of thought for problem solving”. Language paradigms were associated with classes of languages. First the paradigms are defined. Thereafter, programming languages according to the different paradigms are classified. The language paradigms are divided into two parts, imperative and declarative paradigms as shown in the Figure 1. Imperative languages can be further classified into procedural and object oriented approach. Declarative languages can be classified into functional languages and logical languages. In Figure1 the examples of languages in each category are also given.
  7. 7. Language Paradigms Computer programmers have evolved from the early days of the bit processing first generation languages into sophisticated logical designers of complex software applications. A programming paradigm is the logical approach used in software engineering that describes how a programming language is implemented. Programming paradigms are unique to each language within the computer programming domain, and many programming languages utilize multiple paradigms. The term paradigm is best described as a "pattern or model." Therefore, a programming paradigm can be defined as a pattern or model used within a software programming language to create software applications. Programming languages are extremely logical and follow standard rules of mathematics. Each language has a unique method for applying these rules, especially around the areas of functions, variables, methods, and objects. There are many programming paradigms; examples include object oriented, procedural, and structured programming. Each paradigm has unique requirements on the usage and abstractions of processes within the programming language. Features of OOPS Object oriented methods are favored because many experts agree that Object Oriented techniques are more disciplined than conventional structured techniques. (Martin and Odell 1992) The main components of Object Oriented technology are „objects and classes‟, „data abstraction and encapsulation‟, „inheritance‟ and „polymorphism‟. It is very important for you to understand these concepts. Further, in this unit you can find the details of these concepts. a) Object oriented programming (OOP) is a programming model where Programs are organized around object and data rather than action and logic. OOP allow decomposition of a problem into a number of entities called Object and then builds data and function around these objects. b) The Program is divided into number of small units called Object. The data and function are build around these objects. c) The data of the objects can be accessed only by the functions associated with that object. d) The functions of one object can access the functions of other object.
  8. 8. OOP has the following important features. Class: A class is the core of any modern Object Oriented Programming language. In OOP languages it is must to create a class for representing data. Class is a blueprint of an object that contains variables for storing data and functions to performing operations on these data. Class will not occupy any memory space and hence it is only logical representation of data. To create a class, you simply use the keyword "class" followed by the class name: class Employee { } Object: Objects are the basic run-time entities in an object oriented system.They may represent a person,a place "Object is or a any Software item bundle that of the related program variable has to and handle. methods." “Object is an instance of a class” Class will not occupy any memory space. Hence to work with the data represented by the class you must create a variable for the class, which is called as an object. When an object is created by using the keyword new, then memory will be allocated for the class in heap memory area, which is called as an instance and its starting address will be stored in the object in stack memory area.
  9. 9. When an object is created without the keyword new, then memory will not be allocated in heap I.e. instance will not be created and object in the stack contains the value null. When an object contains null, then it is not possible to access the members of the class using that object. class Employee { } Syntax to create an object of class Employee:Employee objEmp = new Employee(); Similarly, the following can be treated as objects in different programming problems: Employees in a payroll system Customers and accounts in a banking system Salesman, products, customers in a sales tracking system Data structures like linked lists, stacks, etc. Hardware devices like magnetic tape drive, keyboard, printer etc. GUI elements like windows, menus, events, etc. in any window-based application.
  10. 10. All the programming languages supporting object oriented Programming will be supporting these three main concepts: 1. Encapsulation 2. Inheritance 3. Polymorphism Abstraction: Abstraction is "To represent the essential feature without representing the back ground details." Abstraction lets you focus on what the object does instead of how it does it. Abstraction provides you a generalized view of your classes or object by providing relevant information. Abstraction is the process of hiding the working style of an object, and showing the information of an object in understandable manner. Real world Example of Abstraction: Suppose you have an object Mobile Phone. Suppose you have 3 mobile phones as following:Nokia 1400 (Features:- Calling, SMS) Nokia 2700 (Features:- Calling, SMS, FM Radio, MP3, Camera) Black Berry (Features:-Calling, SMS, FM Radio, MP3, Camera, Video Recording, Reading E-mails) Abstract information (Necessary and Common Information) for the object "Mobile Phone" is make a call to any number and can send SMS." so that, for mobile phone object you will have abstract class like following:abstract class MobilePhone { public void Calling(); public void SendSMS(); } public class Nokia1400 : MobilePhone { } public class Nokia2700 : MobilePhone {
  11. 11. public void FMRadio(); public void MP3(); public void Camera(); } public class BlackBerry : MobilePhone { public void FMRadio(); public void MP3(); public void Camera(); public void Recording(); public void ReadAndSendEmails(); } Abstraction means putting all the variables and methods in a class which are necessary. For example: - Abstract class and abstract method. Abstraction is the common thing. example: If somebody in your collage tell you to fill application form, you will fill your details like name, address, data of birth, which semester, percentage you have got etc. If some doctor gives you an application to fill the details, you will fill the details like name, address, date of birth, blood group, height and weight. See in the above example what is the common thing? Age, name, address so you can create the class which consist of common thing that is called abstract class. That class is not complete and it can inherit by other class. Encapsulation: Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation. Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object. Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions. class Bag { book; pen; ReadBook(); }
  12. 12. Encapsulation means hiding the internal details of an object, i.e. how an object does something. Encapsulation prevents clients from seeing its inside view, where the behaviour of the abstraction is implemented. Encapsulation is a technique used to protect the information in an object from the other object. Hide the data for security such as making the variables as private, and expose the property to access the private data which would be public. So, when you access the property you can validate the data and set it. Example: class Demo { private int _mark; public int Mark { get { return _mark; } set { if (_mark > 0) _mark = value; else _mark = 0; } } } Real world Example of Encapsulation:Let's take example of Mobile Phone and Mobile Phone Manufacturer Suppose you are a Mobile Phone Manufacturer and you designed and developed a Mobile Phone design(class), now by using machinery you are manufacturing a Mobile Phone(object) for selling, when you sell your Mobile Phone the user only learn how to use the Mobile Phone but not that how this Mobile Phone works. This means that you are creating the class with function and by making object (capsule) of it you are making availability of the functionality of you class by that object and without the interference in the original class. Example-2: TV operation It is encapsulated with cover and we can operate with remote and no need to open TV and change the channel. Here everything is in private except remote so that anyone can access not to operate and change the things in TV.
  13. 13. Inheritance: Inheritance is the process by which objects of one class acquire the properties of objects of another class in the hierarchy. For example, the scooter is a type of the class twowheelers, which is again a type of (or kind of) the class motor vehicles. As shown in the Figure 5 the principle behind it is that the derived class shares common characteristics with the class from which it is derived.New classes can be built from the existing classes. It means that we can add additional features to an existing class without modifying it. The new class is referred as derived class or sub class and the original class is known as base class or super class. Therefore, the concept of inheritance provides the idea of reusability. This inheritance mechanism allows the programmer to reuse a class that is made almost, but not exactly, similar to the required one by adding a few more features to it. As shown in Figure 5, three classes have been derived from one base class. Feature A and Feature B of the base class are inherited in all the three derived classes. Also, each derived class has added its own features according to the requirement. Therefore, new classes use the concept of reusability and extend their functionality. When a class acquire the property of another class is known as inheritance. Inheritance is process of object reusability. For example, A Child acquires property of Parents. public class ParentClass { public ParentClass() { Console.WriteLine("Parent Constructor."); } public void print() { Console.WriteLine("I'm a Parent Class."); } } public class ChildClass : ParentClass { public ChildClass() { Console.WriteLine("Child Constructor."); } public static void Main() { ChildClass child = new ChildClass();
  14. 14. child.print(); } }
  15. 15. Output: Parent Constructor. Child Constructor. I'm a Parent Class. Polymorphism: Polymorphism means one name many forms. One function behaves different forms. In other words, "Many forms of a single object is called Polymorphism." Real World Example of Polymorphism: Example-1: A Teacher behaves to student. A Teacher behaves to his/her seniors. Here teacher is an object but attitude is different in different situation. Example-2: Person behaves SON in house at the same time that person behaves EMPLOYEE in office. Example-3: Your mobile phone, one name but many forms As As As As phone camera mp3 player radio
  16. 16. Difference between Abstraction and Encapsulation:Abstraction Encapsulation 1. Abstraction solves the problem in the 1. Encapsulation solves the problem in the design level. implementation level. 2. Abstraction is used for hiding the 2. Encapsulation means hiding the code and unwanted data and giving relevant data. data into a single unit to protect the data from outside world. 3. Abstraction lets you focus on what the 3. Encapsulation means hiding the internal object does instead of how it does it details or mechanics of how an object does something. 4. Abstraction- Outer layout, used in terms 4. Encapsulation- Inner layout, used in of design. terms of implementation. For Example:- For Example:- Inner Implementation detail of Outer Look of a Mobile Phone, like it has a a Mobile Phone, how keypad button and display screen and keypad buttons to dial a Display Screen are connect with each other number. using circuits. The easier way to understand Abstraction and encapsulation is as follows:Real World Example:Take an example of Mobile Phone:You have a Mobile Phone; you can dial a number using keypad buttons. Even you don't know how these are working internally. This is called Abstraction. You have the only information that is needed to dial a number. But not its internal working of mobile. But how the Mobile Phone internally working?, how keypad buttons are connected with internal circuit? is called Encapsulation.
  17. 17. BENEFITS OF OOPS OOP offers several benefits to both the program developer and the user. The new technology provides greater programmer productivity, better quality of software and lesser maintenance cost. The major benefits are: o Ease in division of job: Since it is possible to map objects of the problem domain to those objects in the program, the work can be easily partitioned based on objects. o Reduce complexity: Software complexity can be easily managed. o Provide extensibility: Object oriented systems can be easily upgraded from small to large system. o Eliminate redundancy: Through inheritance we can eliminate redundant code and extend the use of existing classes. o Saves development time and increases productivity: Instead of writing code from scratch, solutions can be built by using standard working modules. o Allows building secure programs: Data hiding principle helps programmer to build secure programs that cannot be accessed by code in other parts of the program. o Allows designing simpler interfaces: Message passing techniques between objects allows making simpler interface descriptions with external systems. Object Oriented Approach
  18. 18. The salient features of Object oriented programming are: More emphasis is on data rather than procedure. Programs are modularized into entities called objects. Data structures methods characterize the objects of the problem. Since the data is not global, there is no question of any operations other than those defined within the object, accessing the data. Therefore, there is no scope of accidental modification of data. It is easier to maintain programs. The manner in which an object implements its operations is internal to it. Therefore, any change within the object would not affect external objects. Therefore, systems built using objects are resilient to change. Object reusability, which can save many human hours of effort, is possible. An application developer can use objects like „array‟, „list‟, „windows‟, „menus‟, „event‟ and many other components, which were developed by other programmers, in her program and thus reduce program development time. It employs bottom-up approach in program design. SUMMARY OOP is a new way of organizing and developing programs. It eliminates many pitfalls of the conventional programming approach. OOP programs are organized around objects, which contain data and functions that operate on that data. A class is a template for a number of objects. The object is an instance of a class. The major features of OOP are data abstraction, data encapsulation, inheritance and polymorphism.  "Encapsulation is accomplished by using Class. - Keeping data and methods that accesses that data into a single unit"  "Abstraction is accomplished by using Interface. - Just giving the abstract information about what it can do without specifying the back ground details"  "Information/Data hiding is accomplished by using Modifiers - By keeping the instance variables private or protected." This new methodology increases programmer productivity, delivers better quality of software and lessens maintenance cost. Languages that support several OOP concepts include C++, Smalltalk, Object Pascal and Java.
  19. 19. �Check Your Progress 1 1) What do you understand by structured programming? ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… ………………………………………………………………………………… ……… 2) What is the basic idea of Object Oriented approach? ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… ………………………………………………………………………………… ……… 3) Differentiate between Data abstraction and data hiding. ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… …… 4) Differentiate between Inheritance and polymorphism. ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… ………………………………………………………………………………… ……… �Check Your Progress 2 1) State True or False. a) In the procedure-oriented approach, all data are shared by all functions. b) One of the major characteristics of OOP is the division of programs into objects that represent realworld entities. c) Object Oriented programming language permit reusability of the existing code. d) Data is given a second-class status in procedural programming approach.
  20. 20. e) OOP languages permit functional as well as data abstraction 2) Does procedure oriented language support the concept of class? ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… ………………………………………………………………………………… ……… 3) Give the reason of accessing data of a class through its functions only. ………………………………………………………………………………… ……..…………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… ………………………………………………………………………………… ……… �Check Your Progress 3 1) State True or False a) Protecting data from access by unauthorized functions is called data hiding. b) Wrapping up of data of different types and functions into a unit is known as encapsulation. c) Polymorphism can be used in implementing inheritance. d) A Class permits us to build user-defined data types. e) Object Oriented approach cannot be used to create databases. 2) Explain the advantage of dynamic binding. ………………………………………………………………………………… … ………………………………………………………………………………… ………………………………………………………………………………… 3) Differentiate between object based and object oriented programming languages …………………………………………………………………………… …………..……………………………………………………………… …………………………………………………………………………… …………………………………………………………………………… �SOLUTIONS/ANSWERS Check Your Progress 1
  21. 21. 1) In structured programming, a program is divided into functions or modules and each module has a clearly defined purpose and a defined interface to the other functions in the program. Dividing a program into functions and modules is one of the major characteristics of structured programming. Here we are least bothered about the data of the problem provided. Our main objective is to achieve control of the execution of program correctly. 2) In Object Oriented programming (OOP), the program is organized around the data being operated upon rather than the operations performed. The basic idea behind OOP is to combine both, data and its functions that operate on the data into a single unit called object. 3) In data abstraction, data structures are used without having to be concerned about the exact details of implementation. This insulation of the data from direct access by the other elements of the program is known as data hiding. It is achieved through classes in OOPs. 4) Inheritance is the process by which objects of one class acquire the properties of objects of another class in the hierarchy. By using inheritance, new classes can be built from the existing old classes. It means that we can add additional features to an existing class without modifying it. This inheritance mechanism allows the programmer to reuse a class that is almost, but not exactly, similar to the required one by adding a few more features to it. Polymorphism means the ability to take more than one form with the same name. Using polymorphism we can have more than one function with the same name but with different functionalities. Check Your Progress 2 1) False. b) True. c) True. d) True. e) True. 2) Yes procedural languages also support the concept of class, for example, type (data type of the language) is a class and is supported by procedural languages.You know C language support several data types. But procedural languages don‟t support the user-defined class that has data and functions together. 3) Accessing data of a class through its functions is in basic philosophy of object orientation. If data is not having restrictive access and open to all the principle of data hiding is violated and emphasis on data get reduced. Check Your Progress 3
  22. 22. 1) True. b) True. c) True. d) True. e) False. 2) It gives option of run-time selection of methods on the basis of current input during execution of program. Dynamic binding allows new objects and code to be interfaced with or added to a system without affecting existing code. 3) Object based languages support the notion of objects. Object oriented languages support the concept of class and permit inheritance between classes. �Multiple choice/objective type questions 1) Which language is not a true object-oriented programming language? a.) VB.NET b.) VB 6 c.) C++ d.) C# e.) Java Answer: b 2) A GUI: a.) uses buttons, menus, and icons. b.) should be easy for a user to manipulate. c.) stands for Graphic Use Interaction. d.) Both a and b. e.) All of the above. Answer: d 3) An object is composed of: a.) properties. b.) methods. c.) events. d.) Both a and b.
  23. 23. e.) All of the above. Answer: e 4) Which statement about objects is true? a.) One object is used to create one class. b.) One class is used to create one object. c.) One object can create many classes. d.) One class can create many objects. e.) There is no relationship between objects and classes. Answer: d 5) Which is a numeric data type? a.) Floating point b.) Integer c.) Boolean d.) Both a and b. e.) All of the above. Answer: d � Exercise Questions and Answers 1. What is the most important feature of Java? Ans. Java is a platform independent language. 2. What do you mean by platform independence? Ans. Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc). 3. What is a JVM?
  24. 24. Ans. JVM is Java Virtual Machine which is a run time environment for the compiled java class files. 4. Are JVM's platform independent? Ans. JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor. 5. What is the difference between a JDK and a JVM? Ans. JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM. 6. What is a pointer and does Java support pointers? Ans. Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn't support the usage of pointers.  Answer the following questions. (Questions for short notes) 1. Can a private method of a super class be declared within a subclass? 2. Why Java does not support multiple inheritance? 3. In System.out.println (), what is System,out and println,pls explain? 4. What is meant by "Abstract Interface "? 5. Why Java does not support pointers? 6. What is the main difference between Java platform and other platforms? (Questions for short Answer) 1. What is the base class of all classes? 2. Does Java support multiple inheritance? 3. Is Java a pure object oriented language? 4. Are arrays primitive data types? 5. What is difference between Path and Classpath? 6. What are local variables?
  25. 25. Reference 1. Gosling, James, A brief history of the Green project.[dead link] Java.net, no date [ca.Q1/1998]. Retrieved April 29, 2007. 2. Gosling, James, A brief history of the Green project. anonymous-insider.net, no date [ca. Q1/1998]. Retrieved September 4, 2013. 3. Gosling, James; Joy, Bill; Steele, Guy L., Jr.; Bracha, Gilad (2005). The Java Language Specification (3rd ed.). Addison-Wesley. ISBN 0-321-24678-0. 4. Lindholm, Tim; Yelling, Frank (1999). The Java Virtual Machine Specification (2nd ed.). Addison-Wesley. ISBN 0-201-43294-3. 5. "The History of Java Technology". Retrieved October 6, 2012. 6. Java 5.0 added several new language features C# language Gosling, James; and McGilton, Henry (May 1996). "The Java Language Environment". 7. Gosling, James; Joy, Bill; Steele, Guy; and Bracha, Gilad. "The Java Language Specification, 2nd Edition". 8. "The A-Z of Programming Languages: Modula-3". Computerworld.com.au. Retrieved 2010-06-09. 9. Tech Metrix Research (1999). "History of Java". Java Application Servers Report. “Byous, Jon (ca. 1998)."Java technology: The early years". Sun Developer Network. Sun Microsystems. 10. Object-oriented programming "The History of Java Technology". Sun Developer Network. ca. 1995. Retrieved 2010-04-30. 11. "Java Community Process website". Jcp.org. 2010-05-24. Retrieved 2010-06-09. 12. "Learn About Java Technology". Oracle. Retrieved 21 November 2011.

×