Advertisement
udaykumar1997

ss

Mar 4th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.07 KB | None | 0 0
  1. --------------------------
  2. Post Title 'OOC Assignment-4 Answers'
  3. Post by user 'Adusumilli-Uday-Kumar'
  4. Post encryped with secure 256-bit MD5 Encryption
  5. Post accesable only VIA link
  6. Post will Expire on '3-OCT-2017'
  7. --------------------------
  8.  
  9.  
  10.  
  11. Q1.
  12.  
  13. "Write once, run anywhere" (WORA), is a slogan created by Sun Microsystems to illustrate the cross-platform benefits of the Java language. Ideally, this means Java can be developed on any device, compiled into a standard bytecode and be expected to run on any device equipped with a Java virtual machine (JVM).
  14.  
  15. This means a programmer can develop code on a PC and can expect it to run on Java enabled cell phones, as well as on routers and mainframes equipped with Java, without any adjustments. This is intended to save software developers the effort of writing a different version of their software for each platform or operating system they intend to deploy on.
  16.  
  17.  
  18.  
  19. Q2.
  20.  
  21. The key considerations were summed up by the Java team in the following list of buzzwords:
  22. • Simple
  23. • Secure
  24. • Portable
  25. • Object-oriented
  26. • Robust
  27. • Multithreaded
  28. • Architecture-neutral
  29. • Interpreted
  30. • High performance
  31. • Distributed
  32. • Dynamic
  33.  
  34. - Security
  35. Java was able to acheive a high level of security by confining an applet to the Java execution environment and not allowing it access to other parts of the computer. The ability to download applets with confidence that no harm will be done and that no security will be breached is considered by many to be the single most innovative aspect of Java.
  36.  
  37. - Portability
  38. Output of a Java compiler is Non Executable Code i.e Bytecode. Bytecode is executed by Java run-time system, which is called the Java Virtual Machine (JVM). Once JVM is installed for particular system then any java program can run on it. Internal details of JVM will differ from platform to platform but still all understand the Same Java Bytecode.
  39.  
  40. - Simple
  41. Java was designed to be easy for the professional programmer to learn and use effectively. If you already understand the basic concepts of object-oriented programming, learning Java will be even easier. Best of all, if you are an experienced C programmer, moving to Java will require very little effort. Because Java inherits the C/C syntax and many of the object-oriented features of C , most programmers have little trouble learning Java.
  42.  
  43. - Object-Oriented
  44. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance. The object model in Java is simple and easy to extend, while primitive types, such as integers, are kept as high-performance nonobjects.
  45.  
  46. - Robust
  47. In today's world, programs will need to execute reliably in a variety of systems. Thus, the ability to create robust programs was given a high priority in the design of Java. To gain reliability, Java restricts you in a few key areas to force you to find your mistakes early in program development. At the same time, Java frees you from having to worry about many of the most common causes of programming errors. Because Java is a strictly typed language, it checks your code at compile time. However, it also checks your code at run time. Many hard-to-track-down bugs that often turn up in hard-to-reproduce run-time situations are simply impossible to create in Java. Knowing that what you have written will behave in a predictable way under diverse conditions is a key feature of Java.
  48.  
  49. - Multithreaded
  50. Java supports multithreaded programming, which allows you to write programs that do many things simultaneously. The Java run-time system
  51. comes with an elegant yet sophisticated solution for multiprocess synchronization. Java’s easy-to-use approach to multithreading allows you to think about the specific behavior of your program, not the multitasking subsystem.
  52.  
  53. - Architecture-Neutral
  54. A central issue for the Java designers was that of code longevity and portability. Operating system upgrades, processor upgrades, and changes in core system resources can all combine to make a program malfunction. The Java designers made several hard decisions in the Java language and the Java Virtual Machine in an attempt to alter this situation. Their goal was “write once; run anywhere, any time, forever.” To a great extent, this goal was accomplished.
  55.  
  56. - Interpreted and High Performance
  57. Most previous attempts at cross-platform solutions have done so at the expense of performance. The Java bytecode was carefully designed so that it would be easy to translate directly into native machine code for very high performance by using a just-in-time compiler. Java run-time systems that provide this feature lose none of the benefits of the platform-independent code.
  58.  
  59. - Distributed
  60. Java is designed for the distributed environment of the Internet because it handles TCP/IP protocols. In fact, accessing a resource using a URL is not much different from accessing a file. Java also supports Remote Method Invocation (RMI). This feature enables a program to invoke methods across a network.
  61.  
  62. - Dynamic
  63. Java programs carry with them substantial amounts of run-time type information that is used to verify and resolve accesses to objects at run time. This makes it possible to dynamically link code in a safe and expedient manner. This is crucial to the robustness of the Java environment, in which small fragments of bytecode may be dynamically updated on a running system.
  64.  
  65.  
  66.  
  67. Q3.
  68.  
  69. All object-oriented programming languages provide mechanisms that help you implement the object-oriented model.
  70.  
  71. *) Encapsulation
  72. Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. The power of encapsulated code is that everyone knows how to access it and thus can use it regardless of the implementation details—and without fear of unexpected side effects.
  73. In Java, the basis of encapsulation is the class. The data defined by the class are referred to as member variables or instance variables. The code that operates on that data is referred to as member methods or just methods. The behavior and interface of a class are defined by the methods that operate on its instance data.
  74. Since the purpose of a class is to encapsulate complexity, there are mechanisms for hiding the complexity of the implementation inside the class. Each method or variable in a class may be marked private or public. The public interface of a class represents everything that external users of the class need to know, or may know. The private methods and data can only be accessed by code that is a member of the class. Therefore, any other code that
  75. is not a member of the class cannot access a private method or variable. Since the private members of a class may only be accessed by other parts of your program through the class public methods, you can ensure that no improper actions take place.
  76.  
  77. *) Inheritance
  78. Inheritance is the process by which one object acquires the properties of another object. This is important because it supports the concept of hierarchical classification. Most knowledge is made manageable by hierarchical (that is, top-down) classifications.
  79. Without the use of hierarchies, each object would need to define all of its characteristics explicitly. However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.
  80. Inheritance interacts with encapsulation as well. If a given class encapsulates some attributes, then any subclass will have the same attributes plus any that it adds as part of its specialization. A new subclass inherits all of the attributes of all of its ancestors. It does not have unpredictable interactions with the majority of the rest of the code in the system.
  81.  
  82. *) Polymorphism
  83. Polymorphism is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature
  84. of the situation. This means that it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler’s job to select the specific action (that is, method) as it applies to each situation. You, the programmer, do not need to make this selection manually. You need only remember and utilize the general interface.
  85.  
  86. Polymorphism, Encapsulation, and Inheritance Work Together....
  87. When properly applied, polymorphism, encapsulation, and inheritance combine to produce a programming environment that supports the development of far more robust and scalables programs than does the process-oriented model.
  88. - A well-designed hierarchy of classes is the basis for reusing the code in which you have invested time and effort developing and testing.
  89. - Encapsulation allows you to migrate your implementations over time without breaking the code that depends on the public interface of your classes.
  90. - Polymorphism allows you to create clean, sensible, readable, and resilient code.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement