Sun River
          Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
          posts - 78,comments - 0,trackbacks - 0

          --Question: What is similarities/difference between an Abstract class and Interface?
          Answer:  Differences are as follows:

          • Interfaces provide a form of multiple inheritance. A class can extend only one other class.
          • Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
          • A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
          • Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast. 

          Similarities:

          • Neither Abstract classes or Interface can be instantiated.

           --Question: What do you understand by Synchronization?
          Answer: Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value. Synchronization prevents such type of data corruption.
          E.g. Synchronizing a function:
          public synchronized void Method1 () {
               // Appropriate method-related code. 
          }
          E.g. Synchronizing a block of code inside a function:
          public myFunction (){
              synchronized (this) { 
                      // Synchronized code here.
                   }
          }
            
          --Question: What is Collection API?
          Answer: The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces. 
          Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap.
          Example of interfaces: Collection, Set, List and Map.
            --

          Question: Describe the principles of OOPS.
          Answer: There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation.  
           

          Question: Explain the Encapsulation principle.
          Answer: Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.  
           

          Question: Explain the Inheritance principle.
          Answer: Inheritance is the process by which one object acquires the properties of another object.  
           

          Question: Explain the Polymorphism principle.
          Answer: The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods".   

          Question: Explain the different forms of Polymorphism.
          Answer: From a practical programming viewpoint, polymorphism exists in three distinct forms in Java:

          • Method overloading
          • Method overriding through inheritance
          • Method overriding through the Java interface

          --Question: What do you understand by final value?
          Answer: FINAL for a variable: value is constant. FINAL for a method: cannot be overridden. FINAL for a class: cannot be derived.
          --Question: How to convert String to Number in java program?
          Answer: The valueOf() function of Integer class is is used to convert string to Number. Here is the code example:
          String strId = "10"; int id=Integer.valueOf(strId);

          posted on 2007-07-12 03:00 Sun River 閱讀(297) 評論(0)  編輯  收藏 所屬分類: Java SE
          主站蜘蛛池模板: 韩城市| 青田县| 安龙县| 怀来县| 莒南县| 绥化市| 新乡市| 昭通市| 林芝县| 博客| 石泉县| 留坝县| 延安市| 恭城| 慈利县| 新密市| 阿城市| SHOW| 东阳市| 甘德县| 仁寿县| 宜昌市| 通辽市| 普兰县| 镇江市| 乃东县| 长岭县| 贞丰县| 崇文区| 金乡县| 丹凤县| 阜平县| 济阳县| 永寿县| 杭锦后旗| 磐安县| 肇源县| 潍坊市| 益阳市| 金沙县| 安阳县|