Showing posts with label Computer Languages. Show all posts
Showing posts with label Computer Languages. Show all posts

Thursday, September 15, 2011

JAVA Interview Question


What is Collection API ?
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.

Is Iterator a Class or Interface? What is its use?
Answer: Iterator is an interface which is used to step through the elements of a Collection.

What is similarities/difference between an Abstract class and Interface?
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.

Java Interview Questions - How to define an Abstract class?
A class containing abstract method is called Abstract class. An Abstract class can't be instantiated.
Example of Abstract class:
abstract class testAbstractClass {
protected String myString;
public String getMyString() {
return myString;
}
public abstract string anyAbstractFunction();
}

Saturday, April 30, 2011

Kinds of Computer Languages


  • Imperative
    • Specifies how a computation is to be done.
    • Examples: C, C++, C#, Fortran, Java
  • Declarative
    • Specifies what computation is to be done.
    • Examples: Haskell, ML, Prolog
  • von Neumann
    • One whose computational model is based on the von Neumann architecture.
    • Basic means of computation is through the modification of variables (computing via side effects).
    • Statements influence subsequent computations by changing the value of memory.
    • Examples: C, C++, C#, Fortran, Java
  • Object-oriented
    • Program consists of interacting objects.
    • Each object has its own internal state and executable functions (methods) to manage that state.
    • Object-oriented programming is based on encapsulation, modularity, polymorphism, and inheritance.
    • Examples: C++, C#, Java, OCaml, Simula 67, Smalltalk



    • Scripting
      • An interpreted language with high-level operators for "gluing together" computations.
      • Examples: AWK, Perl, PHP, Python, Ruby
    • Functional
      • One whose computational model is based on the recursive definition of functions (lambda calculus).
      • Examples: Haskell, Lisp, ML.
    • Parallel
      • One that allows a computation to run concurrently on multiple processors.
      • Examples
        • Libraries: POSIX threads, MPI
        • Languages: Ada, Cilk, OpenCL, Chapel, X10
        • Architecture: CUDA (parallel programming architecture for GPUs)
    • Domain specific
      • Many areas have special-purpose languages to facilitate the creation of applications.
      • Examples
        • YACC for creating parsers
        • LEX for creating lexical analyzers
        • MATLAB for numerical computations
        • SQL for database applications
    • Markup
      • Not programming languages in the sense of being Turing complete, but widely used for document preparation.
      • Examples: HTML, XHTML, XML