1) Explain about the programming language python?
Python is a very easy language and can be learnt very easily than other programming languages. It is a dynamic object oriented language which can be easily used for software development. It supports many other programming languages and has extensive library support for many other languages.
2) Explain about the use of python for web programming?
Python can be very well used for web programming and it also has some special features which make you to write the programming language very easily. Some of the features which it supports are Web frame works, Cgi scripts, Webservers, Content Management systems, Web services, Webclient programming, Webservices, etc. Many high end applications can be created with Python because of the flexibility it offers.
3) State some programming language features of Python?
Python supports many features and is used for cutting edge technology.
Some of them are
1) A huge pool of data types such as lists, numbers and dictionaries.
2) Supports notable features such as classes and multiple inheritance.
3) Code can be split into modules and packages which assists in flexibility.
4) It has good support for raising and catching which assists in error handling.
5) Incompatible mixing of functions, strings, and numbers triggers an error which also helps in good programming practices.
6) It has some advanced features such as generators and list comprehensions.
7) This programming language has automatic memory management system which helps in greater memory management.
4) How is python interpreted?
Python has an internal software mechanism which makes your programming easy. Program can run directly from the source code. Python translates the source code written by the programmer into intermediate language which is again translated it into the native language of computer. This makes it easy for a programmer to use python.
5) Does python support object oriented scripting?
Python supports object oriented programming as well as procedure oriented programming. It has features which make you to use the program code for many functions other than Python. It has useful objects when it comes to data and functionality. It is very powerful in object and procedure oriented programming when compared to powerful languages like C or Java.
6) Describe about the libraries of Python?
Python library is very huge and has some extensive libraries. These libraries help you do various things involving CGI, documentation generation, web browsers, XML, HTML, cryptography, Tk, threading, web browsing, etc. Besides the standard libraries of python there are many other libraries such as Twisted, wx python, python imaging library, etc.
7) State and explain about Strings?
Strings are almost used everywhere in python. When you use single and double quotes for a statement in python it preserves the white spaces as such. You can use double quotes and single quotes in triple quotes. There are many other strings such as raw strings, Unicode strings, once you have created a string in Python you can never change it again.
8) Explain about classes in strings?
Classes are the main feature of any object oriented programming. When you use a class it creates a new type. Creating class is the same as in other programming languages but the syntax differs. Here we create an object or instance of the class followed by parenthesis.
9) What is tuple?
Tuples are similar to lists. They cannot be modified once they are declared. They are similar to strings. When items are defined in parenthesis separated by commas then they are called as Tuples. Tuples are used in situations where the user cannot change the context or application; it puts a restriction on the user.
10) Explain and statement about list?
As the name specifies list holds a list of data items in an orderly manner. Sequence of data items can be present in a list. In python you have to specify a list of items with a comma and to make it understand that we are specifying a list we have to enclose the statement in square brackets. List can be altered at any time.
11) Explain about the dictionary function in Python?
A dictionary is a place where you will find and store information on address, contact details, etc. In python you need to associate keys with values. This key should be unique because it is useful for retrieving information. Also note that strings should be passed as keys in python. Notice that keys are to be separated by a colon and the pairs are separated themselves by commas. The whole statement is enclosed in curly brackets.
12) Explain about indexing and slicing operation in sequences?
Tuples, lists and strings are some examples about sequence. Python supports two main operations which are indexing and slicing. Indexing operation allows you to fetch a particular item in the sequence and slicing operation allows you to retrieve an item from the list of sequence. Python starts from the beginning and if successive numbers are not specified it starts at the last. In python the start position is included but it stops before the end statement.
13) Explain about raising error exceptions
In python programmer can raise exceptions using the raise statement. When you are using exception statement you should also specify about error and exception object. This error should be related to the derived class of the Error. We can use this to specify about the length of the user name, password field, etc.
14) What is a Lambda form?
This lambda statement is used to create a new function which can be later used during the run time. Make_repeater is used to create a function during the run time and it is later called at run time. Lambda function takes expressions only in order to return them during the run time.
15) Explain about assert statement?
Assert statement is used to assert whether something is true or false. This statement is very useful when you want to check the items in the list for true or false function. This statement should be predefined because it interacts with the user and raises an error if something goes wrong.
16) Explain about repr function?
This function is used to obtain a string representation of an object. This function helps you in obtaining a printable representation of the object. This function also makes it possible to obtain specific return from the object. This can be made possible by specifying the repr method in the class.
17) Explain about pickling and unpickling?
Python has a standard module known as Pickle which enables you to store a specific object at some destination and then you can call the object back at later stage. While you are retrieving the object this process is known as unpickling. By specifying the dump function you can store the data into a specific file and this is known as pickling.
Ruby (Part-I) Interview question and answers
1) Explain about the programming language ruby?
Ruby is the brain child of a Japanese programmer Matz. He created Ruby. It is a cross platform object oriented language. It helps you in knowing what your code does in your application. With legacy code it gives you the power of administration and organization tasks. Being open source, it did go into great lengths of development.
2) Explain about class libraries in ruby?
Ruby has a strong set of class libraries and it covers from a variety of domains such as thread programming, domains and data types. Also ruby is a new language and it also has additional libraries coming every day. Many of the new languages which do exist have huge libraries because of their age.
3) Explain about portability?
Ruby language can be ported to many platforms. Ruby programs can be ported to many platforms without any modification to the source code. This feature made the language very useful and highly used by many programmers worldwide. Some of the platforms used are DOS, UNIX, WINDOWS, etc.
4) Explain about garbage collection feature of ruby?
Ruby is an object oriented language and every object oriented language tends to allocate many objects during execution of the program. Ruby deletes unallocated and unused objects automatically. This feature can be controlled by applying proper syntax and program through ruby.
5) Explain about the command line options?
Ruby`s language is executed from the command line like most of the scripting languages. Programming and behavior language environment can be controlled from the interpreter itself. Some of the commands which are used are as follows –d, -h, -e prog, -v, -T, -r lib, etc.
6) Explain about environment variables present in ruby?
Following are some of the environment variables used to control the behavior programming of ruby. While programming ENV object lists some of the current variables. RUBYLIB path searches for libraries. Make sure that you separate each path with colons. RUBYOPT passes command line options to Ruby interpreter. There are many more which can be obtained by searching the huge pool of library.
7) Explain about operators in Ruby?
Like all the modern languages Ruby supports many different operators to its credit. Most of the operators in Ruby are in fact methods due to the object oriented nature of the language. This feature gives Ruby an edge over its competitors. Semantics of these operators can be changed due to the object oriented nature of the language.
8) Explain about the defined operator?
Define operator defines whether a passed expression is defined or not. If the expression is defined it returns the description string or null if the expression is not defined. If a variable is defined it gets initialized. If method_call is defined as true then method also gets defined. This is also the same case with super and yield.
9) Explain about methods?
Methods in ruby basically perform two functions, named operation and the code present in the class which does a specific function. In Ruby all your algorithms live in methods which inturn is present on objects. Ruby does not have any provision for functions. Code present in Ruby is always a method of some object. Behind the scenes ruby gives you the flexibility to work with methods as functions if you are considering working with other languages.
10) Explain about normal method class?
This function calls a method and it can take any number of arguments and expr. Make sure that you put an asterisk or an ampersand before the expression. Last expr argument can be declared with a hash without any braces. If you want to increase the size of the array value then make sure that you put an asterisk before expression. “::” can be used to separate the class from methods.
11) Explain about ruby names?
Classes, variables, methods, constants and modules can be referred by ruby names. When you want to distinguish between various names you can specify that by the first character of the name. Some of the names are used as reserve words which should not be used for any other purpose. A name can be lowercase letter, upper case letter, number, or an underscore, make sure that you follow the name by name characters.
12) Explain about variables?
There are four different types of variables they are local, instance, global, and class. Variables can be used in the program without any declaration and they can contain data of any type. A local variable contains lower case characters followed by name characters. Instance variable starts with a @ sign followed by name characters.
13) Explain about Class variable and global variable?
A class variable starts with an @@ sign which is immediately followed by upper or lower case letter. You can also put some name characters after the letters which stand to be a pure optional. A class variable can be shared among all the objects of a class. A single copy of a class variable exists for each and every given class.
To write a global variable you start the variable with a $ sign which should be followed by a name character. Ruby defines a number of global variables which also include other punctuation characters such as $_ and $-k.
14) How does ruby deal with extremely large numbers?
Unlike other programming languages ruby deals with extremely large numbers it doesn’t have any barriers. There is no limit on the extent of limit of number usage. Ruby performs this function with two different classes they are fixnum and bignum. Fixnum represents easily managed small numbers and bignum represents big numbers. Ruby entirely handles the functioning of these two classes which leaves a programmer to concentrate on his arithmetic operations.
15) Explain about Float, Dig and Max?
Float class is used whenever the function changes constantly. It acts as a sub class of numeric. They represent real characters by making use of the native architecture of the double precision floating point.
Max is used whenever there is a huge need of Float.
Dig is used whenever you want to represent a float in decimal digits.
16) Explain about interpolation?
Interpolation is a very important process in Ruby. Interpolation is the process of inserting a string into a literal. There is only one way in which you can interpolate a string into a literal by placing a Hash (#) within {} open and close brackets. This refers to a new name to by referring to the copy of the original method.
17) Explain about ruby code blocks?
Ruby code blocks form an important part of ruby and are very fun to use. With the help of this feature you can place your code between do-end and you can associate them with method invocations and you can get an impression that they are like parameters. They may appear near to a source of the code and adjacent to a method call. The code is not executed during the program execution but it is executed when the context of its appearance is met or when it enters a method.
Ruby is the brain child of a Japanese programmer Matz. He created Ruby. It is a cross platform object oriented language. It helps you in knowing what your code does in your application. With legacy code it gives you the power of administration and organization tasks. Being open source, it did go into great lengths of development.
2) Explain about class libraries in ruby?
Ruby has a strong set of class libraries and it covers from a variety of domains such as thread programming, domains and data types. Also ruby is a new language and it also has additional libraries coming every day. Many of the new languages which do exist have huge libraries because of their age.
3) Explain about portability?
Ruby language can be ported to many platforms. Ruby programs can be ported to many platforms without any modification to the source code. This feature made the language very useful and highly used by many programmers worldwide. Some of the platforms used are DOS, UNIX, WINDOWS, etc.
4) Explain about garbage collection feature of ruby?
Ruby is an object oriented language and every object oriented language tends to allocate many objects during execution of the program. Ruby deletes unallocated and unused objects automatically. This feature can be controlled by applying proper syntax and program through ruby.
5) Explain about the command line options?
Ruby`s language is executed from the command line like most of the scripting languages. Programming and behavior language environment can be controlled from the interpreter itself. Some of the commands which are used are as follows –d, -h, -e prog, -v, -T, -r lib, etc.
6) Explain about environment variables present in ruby?
Following are some of the environment variables used to control the behavior programming of ruby. While programming ENV object lists some of the current variables. RUBYLIB path searches for libraries. Make sure that you separate each path with colons. RUBYOPT passes command line options to Ruby interpreter. There are many more which can be obtained by searching the huge pool of library.
7) Explain about operators in Ruby?
Like all the modern languages Ruby supports many different operators to its credit. Most of the operators in Ruby are in fact methods due to the object oriented nature of the language. This feature gives Ruby an edge over its competitors. Semantics of these operators can be changed due to the object oriented nature of the language.
8) Explain about the defined operator?
Define operator defines whether a passed expression is defined or not. If the expression is defined it returns the description string or null if the expression is not defined. If a variable is defined it gets initialized. If method_call is defined as true then method also gets defined. This is also the same case with super and yield.
9) Explain about methods?
Methods in ruby basically perform two functions, named operation and the code present in the class which does a specific function. In Ruby all your algorithms live in methods which inturn is present on objects. Ruby does not have any provision for functions. Code present in Ruby is always a method of some object. Behind the scenes ruby gives you the flexibility to work with methods as functions if you are considering working with other languages.
10) Explain about normal method class?
This function calls a method and it can take any number of arguments and expr. Make sure that you put an asterisk or an ampersand before the expression. Last expr argument can be declared with a hash without any braces. If you want to increase the size of the array value then make sure that you put an asterisk before expression. “::” can be used to separate the class from methods.
11) Explain about ruby names?
Classes, variables, methods, constants and modules can be referred by ruby names. When you want to distinguish between various names you can specify that by the first character of the name. Some of the names are used as reserve words which should not be used for any other purpose. A name can be lowercase letter, upper case letter, number, or an underscore, make sure that you follow the name by name characters.
12) Explain about variables?
There are four different types of variables they are local, instance, global, and class. Variables can be used in the program without any declaration and they can contain data of any type. A local variable contains lower case characters followed by name characters. Instance variable starts with a @ sign followed by name characters.
13) Explain about Class variable and global variable?
A class variable starts with an @@ sign which is immediately followed by upper or lower case letter. You can also put some name characters after the letters which stand to be a pure optional. A class variable can be shared among all the objects of a class. A single copy of a class variable exists for each and every given class.
To write a global variable you start the variable with a $ sign which should be followed by a name character. Ruby defines a number of global variables which also include other punctuation characters such as $_ and $-k.
14) How does ruby deal with extremely large numbers?
Unlike other programming languages ruby deals with extremely large numbers it doesn’t have any barriers. There is no limit on the extent of limit of number usage. Ruby performs this function with two different classes they are fixnum and bignum. Fixnum represents easily managed small numbers and bignum represents big numbers. Ruby entirely handles the functioning of these two classes which leaves a programmer to concentrate on his arithmetic operations.
15) Explain about Float, Dig and Max?
Float class is used whenever the function changes constantly. It acts as a sub class of numeric. They represent real characters by making use of the native architecture of the double precision floating point.
Max is used whenever there is a huge need of Float.
Dig is used whenever you want to represent a float in decimal digits.
16) Explain about interpolation?
Interpolation is a very important process in Ruby. Interpolation is the process of inserting a string into a literal. There is only one way in which you can interpolate a string into a literal by placing a Hash (#) within {} open and close brackets. This refers to a new name to by referring to the copy of the original method.
17) Explain about ruby code blocks?
Ruby code blocks form an important part of ruby and are very fun to use. With the help of this feature you can place your code between do-end and you can associate them with method invocations and you can get an impression that they are like parameters. They may appear near to a source of the code and adjacent to a method call. The code is not executed during the program execution but it is executed when the context of its appearance is met or when it enters a method.
c,c++(Part-V) interview question and answers
Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?
A: There is nothing like Virtual Constructor. The constructor can’t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can’t be delegated to any other object by virtual keyword means.
Q: What is Constructor ?
A: Constructor creates an object and initializes it. It also creates V-Table for virtual functions. It is different from other methods in a class.
Q: What about Virtual Destructor?
A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.
Q: What is the difference between a copy constructor and an overloaded assignment operator?
A: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Q: Can a constructor throws an exception? How to handle the error when the constructor fails?
A: The constructor never throws an error.
Q: What is default constructor?
A: Constructor with no arguments or all the arguments has default values.
Q: What is default (Implicit) copy constructor?
A: Constructor which initializes it's object member variables (by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you.
Examples:
(a) Boo Obj1(10); // calling Boo constructor
(b) Boo Obj2(Obj1); // calling boo copy constructor
(c) Boo Obj2 = Obj1;// calling boo copy constructor
Q: When is copy constructors called?
A: Copy constructors are called in following cases:
(a) When a function returns an object of that class by value
(b) When the object of that class is passed by value as an argument to a function
(c) When you construct an object based on another object of the same class
(d) When compiler generates a temporary object
Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Q: What is conversion constructor?
A: constructor with a single argument makes that constructor as conversion ctor and it can be used for type conversion.
Example:
class Boo
{
public:
Boo( int i );
};
Boo BooObject = 10 ; // assigning int 10 Boo object
Q:What is conversion operator??
A:class can have a public method for specific data type conversions.
For example:
class Boo
{
double value;
public:
Boo(int i )
operator double()
{
return value;
}
};
Boo BooObject;
double i = BooObject; // assigning object to variable i of type double. now conversion operator gets called to assign the value.
Q: How can I handle a constructor that fails?
A: throw an exception. Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.
Q: How can I handle a destructor that fails?
A: Write a message to a log-_le. But do not throw an exception. The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bare) { handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead.
Q: What is Virtual Destructor?
A: Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes. if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.
Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Q: What's the order that local objects are destructed?
A: In reverse order of construction: First constructed, last destructed. In the following example, b's destructor will be executed first, then a's destructor:
void userCode()
{
Fred a;
Fred b;
...
}
Q: What's the order that objects in an array are destructed?
A: In reverse order of construction: First constructed, last destructed. In the following example, the order for destructors will be a[9], a[8], ..., a[1], a[0]:
void userCode()
{
Fred a[10];
...
}
A: There is nothing like Virtual Constructor. The constructor can’t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can’t be delegated to any other object by virtual keyword means.
Q: What is Constructor ?
A: Constructor creates an object and initializes it. It also creates V-Table for virtual functions. It is different from other methods in a class.
Q: What about Virtual Destructor?
A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.
Q: What is the difference between a copy constructor and an overloaded assignment operator?
A: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Q: Can a constructor throws an exception? How to handle the error when the constructor fails?
A: The constructor never throws an error.
Q: What is default constructor?
A: Constructor with no arguments or all the arguments has default values.
Q: What is default (Implicit) copy constructor?
A: Constructor which initializes it's object member variables (by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you.
Examples:
(a) Boo Obj1(10); // calling Boo constructor
(b) Boo Obj2(Obj1); // calling boo copy constructor
(c) Boo Obj2 = Obj1;// calling boo copy constructor
Q: When is copy constructors called?
A: Copy constructors are called in following cases:
(a) When a function returns an object of that class by value
(b) When the object of that class is passed by value as an argument to a function
(c) When you construct an object based on another object of the same class
(d) When compiler generates a temporary object
Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Q: What is conversion constructor?
A: constructor with a single argument makes that constructor as conversion ctor and it can be used for type conversion.
Example:
class Boo
{
public:
Boo( int i );
};
Boo BooObject = 10 ; // assigning int 10 Boo object
Q:What is conversion operator??
A:class can have a public method for specific data type conversions.
For example:
class Boo
{
double value;
public:
Boo(int i )
operator double()
{
return value;
}
};
Boo BooObject;
double i = BooObject; // assigning object to variable i of type double. now conversion operator gets called to assign the value.
Q: How can I handle a constructor that fails?
A: throw an exception. Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.
Q: How can I handle a destructor that fails?
A: Write a message to a log-_le. But do not throw an exception. The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding. During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bare) { handler? There is no good answer:either choice loses information. So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead.
Q: What is Virtual Destructor?
A: Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes. if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.
Q: Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
A: No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.
Q: What's the order that local objects are destructed?
A: In reverse order of construction: First constructed, last destructed. In the following example, b's destructor will be executed first, then a's destructor:
void userCode()
{
Fred a;
Fred b;
...
}
Q: What's the order that objects in an array are destructed?
A: In reverse order of construction: First constructed, last destructed. In the following example, the order for destructors will be a[9], a[8], ..., a[1], a[0]:
void userCode()
{
Fred a[10];
...
}
c,c++(Part-IV) interview question and answers
Q. What is a modifier?
Answer:
A modifier, also called a modifying function is a member function that changes the value of at least one data member. In other words, an operation that modifies the state of an object. Modifiers are also known as ‘mutators’.
Q. What is an accessor?
Answer:
An accessor is a class operation that does not modify the state of an object. The accessor functions need to be declared as const operations
Q. Differentiate between a template class and class template.
Answer:
Template class: A generic definition or a parameterized class not instantiated until the client provides the needed information. It’s jargon for plain templates.
Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It’s jargon for plain classes.
Q. When does a name clash occur?
Answer:
A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes.
Q. Define namespace.
Answer:
It is a feature in c++ to minimize name collisions in the global name space. This namespace keyword assigns a distinct name to a library that allows other libraries to use the same identifier names without creating any name collisions. Furthermore, the compiler uses the namespace signature for differentiating the definitions.
Q. What is the use of ‘using’ declaration.
Answer:
A using declaration makes it possible to use a name from a namespace without the scope operator.
Q. What is an Iterator class?
Answer:
A class that is used to traverse through the objects maintained by a container class.
There are five categories of iterators:
input iterators,
output iterators,
forward iterators,
bidirectional iterators,
random access.
An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class.
The simplest and safest iterators are those that permit read-only access to the contents of a container class. The following code fragment shows how an iterator might appear in code:
cont_iter:=new cont_iterator();
x:=cont_iter.next();
while x/=none do
...
s(x);
...
x:=cont_iter.next();
end;
In this example, cont_iter is the name of the iterator. It is created on the first line by instantiation of cont_iterator class, an iterator class defined to iterate over some container class, cont. Succesive elements from the container are carried to x. The loop terminates when x is bound to some empty value. (Here, none)In the middle of the loop, there is s(x) an operation on x, the current element from the container. The next element of the container is obtained at the bottom of the loop.
Q. List out some of the OODBMS available.
Answer:
GEMSTONE/OPAL of Gemstone systems.
ONTOS of Ontos.
Objectivity of Objectivity inc.
Versant of Versant object technology.
Object store of Object Design.
ARDENT of ARDENT software.
POET of POET software.
Q. List out some of the object-oriented methodologies.
Answer:
Object Oriented Development (OOD) (Booch 1991,1994).
Object Oriented Analysis and Design (OOA/D) (Coad and Yourdon 1991).
Object Modelling Techniques (OMT) (Rumbaugh 1991).
Object Oriented Software Engineering (Objectory) (Jacobson 1992).
Object Oriented Analysis (OOA) (Shlaer and Mellor 1992).
The Fusion Method (Coleman 1991).
C++(part-II) interview question and answers
1) Contrast and state the difference between visual c++ and ANSI c++?
Visual C++ deals with graphical user interface and is the most advanced IDE for creating complex applications. This is used to create real time applications.
ANSI C++ is the updated and advanced version than the earlier versions of C++. Libraries and functions are updated in ANSI C++ compared to the earlier versions.
2) State the difference between the structure for C and C++?
The main difference between the structure of C and C++ is, C struct can contain only data and C++ has access limitations and contains functions such as public, private, etc.
3) Define about template in C++ and instantiation?
The C++ feature that supports the definition of an object of undetermined type is called a template. Using a template allows the programmer to define the features of the class, while reserving the option of binding the type of the class to the class itself until a class of a particular type is actually needed. The creation of a class of a particular type is called instantiation.
4) Define and explain about the classes in C++ comparing with C?
A C++ class builds on the concept of a structure. Whereas a C structure is a collection of named fields, a C++ class is a collection of named fields and methods that apply to objects of that class type. Additionally, the C++ language implements the concept of information hiding, restricting access to certain members of the class to methods of the class itself.
5) Explain about rational class?
Rational class contains two data members, numerator and denominator and seven method members, reduce, add, multiply, divide, equal, print, and set rational. The methods in the class Rational explicitly mention only one. This is because the class object for which they are invoked is an implicit parameter for each routine.
6) Explain about Templates in C++?
C++ templates are used to optimize code. They are very powerful as they help the program by providing various classes, functions and methods. There is also a disadvantage when we are using C++ templates, they tend to duplicate themselves and get installed which slows down the functioning of the program. This is avoided in Java.
7) Explain Encapsulation and differentiate with regards to C.
Encapsulation is an entirely new concept which is present in C++ but not in C. In Encapsulation you can restrict the access of the functions to Public, private and Protected which is not possible in C. It is a general practice among programmers to allow only partial functions which can help in designing to be public while the rest of the code is made into private or protected.
8) Explain multiple inheritances in C++?
Multiple inheritances in C++ are a controversial issue. In multiple inheritance a derived class or an unrelated class can obtain function of the base class. In this process it can obtain multiple inheritance. A derived class or unrelated class may obtain more than one base class. This can benefit as well as destroy the structure of the program.
9) Explain about virtual member functions of C++?
Virtual member functions come into play when a function belonging to a derived class over rides a base class. This is possible only when there are many similarities in the number of parameters, function definition, object, etc. This increasingly becomes difficult to process during the run time. At this point of time virtual member functions comes to rescue. This overwhelming task is made easy by virtual functions tables.
10) Explain the basic steps to parse a C++ source code?
The main difficulty to parse a C++ code lies in the complex definitions of C++ identifiers. They should also satisfy complex scoping rules for C++. Also they should define what type it is and to what type it belongs to. It should also satisfy the basic criteria of parsing source code.
11) Explain about different problems which C++ faces today.
The main problem which C++ faces today is because of its large feature set. It is almost similar to C language because of which much of the criticism faced by “C” is faced by C++. It doesn’t have language features to create multi threaded software. Also this language is unruly compared to modern languages such as Java which has both object oriented and procedural programming.
12) Explain about name spaces?
Namespaces help you to group classes, functions, etc under one name which helps you to access it at later stage. To access these name spaces we can use scope operator. During name space naming there arises difficulty when a function uses the same name which causes redefinition errors.
13) Explain about exceptions and its relation to handlers?
This function is used for exceptional circumstances and this is made possible by handlers. This exception handler is placed in the code which throws exception and error. This exception throws error when the condition is not satisfied. This handler is placed in a try block in which throw function is present. After the try block a catch function is placed through which exception handlers are declared.
14) Explain about static_cast?
Static cast is very helpful for conversions from pointers to related class and also from derived class to base class. This static_cast is also helpful to convert base class to derived class. Static_cast makes sure that atleast classes and objects are completed. This has its disadvantages such as programmer should ensure that the object specified is being moved to its destination.
15) Explain about reinterpret_cast?
Reinterpret_cast is platform specific. The code generated for reinterpret_cast is generated for the platform which makes it not useful for inter operability. This transfers pointers, irrespective of classes. This forms a image of the specific class and also pointer pointed or the pointer itself is not checked. This can lead doors to security lapses.
16) Explain about explicit conversion within C++ and its supportability?
This explicit conversion is required where there is different interpretation on value. There are two different types of explicit conversion such as c like casting and functional. This explicit conversion can be applied indiscriminately on the code which significantly increases errors during run time.
17) Explain about implicit conversion in relation to C++?
Implicit conversion does not require any operator for performing its function. It automatically performs when a value is copied to the code. The only exception being, it should be compatible. This allows conversions between bool to numerical types, pointer conversions, and etc. significant runtime errors get reduced with this implicit conversion because it accepts values which are compatible.
18) Explain about the class string stream?
This string stream class is defined by a standard header file . This class provides flexibility in converting a string based object to stream. This is useful in extraction and insertion of numerical, strings, characters, etc. This is useful to extract a specific numerical from a string. This also aids in insertion.
19) What exactly a data structure performs in C++?
A data structure is a collection of data elements under one name. These data elements are collectively known as members and they can have variable lengths and types. Structure_name and object_name are two important types defined in C++. Structure types are defined by structure_name and object_name contains valid identifiers.
20) I am getting an error at runtime for an oversized array but it never shows it as a fault during debugging?
In C++ it is very correct syntactically to declare over sized array. It also never shows you any error during compilation but it shows error during run time. The answer lies in pointers. This problem can be mitigated if we can manually specify the memory location by using a reference operator. Automatically pointers assign the variable to a certain location and when it tries to extract during extraction it fails thus creating error
Visual C++ deals with graphical user interface and is the most advanced IDE for creating complex applications. This is used to create real time applications.
ANSI C++ is the updated and advanced version than the earlier versions of C++. Libraries and functions are updated in ANSI C++ compared to the earlier versions.
2) State the difference between the structure for C and C++?
The main difference between the structure of C and C++ is, C struct can contain only data and C++ has access limitations and contains functions such as public, private, etc.
3) Define about template in C++ and instantiation?
The C++ feature that supports the definition of an object of undetermined type is called a template. Using a template allows the programmer to define the features of the class, while reserving the option of binding the type of the class to the class itself until a class of a particular type is actually needed. The creation of a class of a particular type is called instantiation.
4) Define and explain about the classes in C++ comparing with C?
A C++ class builds on the concept of a structure. Whereas a C structure is a collection of named fields, a C++ class is a collection of named fields and methods that apply to objects of that class type. Additionally, the C++ language implements the concept of information hiding, restricting access to certain members of the class to methods of the class itself.
5) Explain about rational class?
Rational class contains two data members, numerator and denominator and seven method members, reduce, add, multiply, divide, equal, print, and set rational. The methods in the class Rational explicitly mention only one. This is because the class object for which they are invoked is an implicit parameter for each routine.
6) Explain about Templates in C++?
C++ templates are used to optimize code. They are very powerful as they help the program by providing various classes, functions and methods. There is also a disadvantage when we are using C++ templates, they tend to duplicate themselves and get installed which slows down the functioning of the program. This is avoided in Java.
7) Explain Encapsulation and differentiate with regards to C.
Encapsulation is an entirely new concept which is present in C++ but not in C. In Encapsulation you can restrict the access of the functions to Public, private and Protected which is not possible in C. It is a general practice among programmers to allow only partial functions which can help in designing to be public while the rest of the code is made into private or protected.
8) Explain multiple inheritances in C++?
Multiple inheritances in C++ are a controversial issue. In multiple inheritance a derived class or an unrelated class can obtain function of the base class. In this process it can obtain multiple inheritance. A derived class or unrelated class may obtain more than one base class. This can benefit as well as destroy the structure of the program.
9) Explain about virtual member functions of C++?
Virtual member functions come into play when a function belonging to a derived class over rides a base class. This is possible only when there are many similarities in the number of parameters, function definition, object, etc. This increasingly becomes difficult to process during the run time. At this point of time virtual member functions comes to rescue. This overwhelming task is made easy by virtual functions tables.
10) Explain the basic steps to parse a C++ source code?
The main difficulty to parse a C++ code lies in the complex definitions of C++ identifiers. They should also satisfy complex scoping rules for C++. Also they should define what type it is and to what type it belongs to. It should also satisfy the basic criteria of parsing source code.
11) Explain about different problems which C++ faces today.
The main problem which C++ faces today is because of its large feature set. It is almost similar to C language because of which much of the criticism faced by “C” is faced by C++. It doesn’t have language features to create multi threaded software. Also this language is unruly compared to modern languages such as Java which has both object oriented and procedural programming.
12) Explain about name spaces?
Namespaces help you to group classes, functions, etc under one name which helps you to access it at later stage. To access these name spaces we can use scope operator. During name space naming there arises difficulty when a function uses the same name which causes redefinition errors.
13) Explain about exceptions and its relation to handlers?
This function is used for exceptional circumstances and this is made possible by handlers. This exception handler is placed in the code which throws exception and error. This exception throws error when the condition is not satisfied. This handler is placed in a try block in which throw function is present. After the try block a catch function is placed through which exception handlers are declared.
14) Explain about static_cast?
Static cast is very helpful for conversions from pointers to related class and also from derived class to base class. This static_cast is also helpful to convert base class to derived class. Static_cast makes sure that atleast classes and objects are completed. This has its disadvantages such as programmer should ensure that the object specified is being moved to its destination.
15) Explain about reinterpret_cast?
Reinterpret_cast is platform specific. The code generated for reinterpret_cast is generated for the platform which makes it not useful for inter operability. This transfers pointers, irrespective of classes. This forms a image of the specific class and also pointer pointed or the pointer itself is not checked. This can lead doors to security lapses.
16) Explain about explicit conversion within C++ and its supportability?
This explicit conversion is required where there is different interpretation on value. There are two different types of explicit conversion such as c like casting and functional. This explicit conversion can be applied indiscriminately on the code which significantly increases errors during run time.
17) Explain about implicit conversion in relation to C++?
Implicit conversion does not require any operator for performing its function. It automatically performs when a value is copied to the code. The only exception being, it should be compatible. This allows conversions between bool to numerical types, pointer conversions, and etc. significant runtime errors get reduced with this implicit conversion because it accepts values which are compatible.
18) Explain about the class string stream?
This string stream class is defined by a standard header file . This class provides flexibility in converting a string based object to stream. This is useful in extraction and insertion of numerical, strings, characters, etc. This is useful to extract a specific numerical from a string. This also aids in insertion.
19) What exactly a data structure performs in C++?
A data structure is a collection of data elements under one name. These data elements are collectively known as members and they can have variable lengths and types. Structure_name and object_name are two important types defined in C++. Structure types are defined by structure_name and object_name contains valid identifiers.
20) I am getting an error at runtime for an oversized array but it never shows it as a fault during debugging?
In C++ it is very correct syntactically to declare over sized array. It also never shows you any error during compilation but it shows error during run time. The answer lies in pointers. This problem can be mitigated if we can manually specify the memory location by using a reference operator. Automatically pointers assign the variable to a certain location and when it tries to extract during extraction it fails thus creating error
JDBC (part-II) interview question amd answers
1) Explain in detail about JDBC and its general features?
JDBC defines the connectivity pattern between the client and his route to database. Querying and updating method is provided in JDBC. It is primarily based on RelationalDBMS. It is a part of the Java Standard edition. JDBC classes are present in the Java package.
2) Explain about multiple implementations and drive manager?
JDBC is liberal in the usage and representation of multiple implementations in the same application. It provides a feature by which it allows loading of correct Java packages and registering them with Driver manager. A Driver manager is primarily responsible for creating JDBC connections.
3) What are the different types of JDBC drivers?
There are many implementations of JDBC drivers out of which some types are: -
• Drivers which implement JDBC API as mapping to another data access API.
• Drivers written in Java programming and in native code.
• Drivers which communicate with middle ware server using database independent protocol.
• Drivers which implement network protocol and are present in pure Java.
4) What are the different classes through which JDBC represents statements?
Statements are represented in JDBC using one of these classes: -
• Statement
• PreparedStatement
• CallableStatement
Stored procedures can also be invoked through JDBC.
5) Explain what should be done when a SQL exception is raised?
SQL exception is raised when a data base operation fails. The chances of recovering the lost database is meager apart from logging the file with much detail one can translate the SQL exception into application domain which will eventually result in a roll back which may solve the problem to a certain extent.
6) Explain about the drive manager class working?
To manager a set of drivers available to JDBC a driver manager class needs to work with Driver interface. When a client requests for a specific connection by providing a URL it is the responsibility of driver manager to find a driver which can recognize that particular URL and that URL should be used for connecting to a database.
7) Why do you use a data source object for a connection?
Data source object uses a logical name for a data source and this feature increases application portability. This removes the necessity of supplying information to each and every driver. Data source can be configured manually or automatically.
8) State the three different ways in which you can create a table?
Tables can be created in three different ways they are: -
1) Using IDE graphical interface
2) Using ANT framework
3) JDBC SQL written into a framework.
9) Explain the process of creating tables using NetBeans IDE?
Although Vendors provide specific GUI which can create tables, they can also be created using NetBeans IDE. Databases can be created either through pull-down menu or by right clicking database. Clicking on the Tables icon select BBB create table. Changes can be made to that specific table by right clicking on them.
10) How do you determine the sensitivity of the ResultSet object?
Sensitivity of ResultSet object is determined in three ways they are: -
1) TYPE_FORWARD_ONLY: -It contains rows which satisfied the query. These rows are satisfied either at the time of execution or as the rows are retrieved.
2) TYPE_SCROLL_INSENSITIVE: - Here the cursor can move forward backward or to an absolute position.
3) TYPE_SCROLL_SENSITIVE: - This works in the same way as the Scroll insensitive.
11) Explain about column name and getter method?
Getter methods have column names as inputs and they are case sensitive. In case a column has more than one name or similar names it considers the value of the first name and it returns search for the first name only. If columns are not explicitly named then it searches with the numbering.
12) Give an example for getXXX method?
This command retrieves the value present in each column. Consider you created a table with name KAR_NAME the first column present in each row stores a value of SQL type VARCHAR. Usual method which can be used for retrieving a value of SQL type varchar or (variable character) is getstring.
13) What are the methods which can verify about the cursor particular position?
In addition to these methods there are other four methods which let you verify the position of the cursor they are isFirst, isLast, isBeforeFirst, isAfterLast. All these methods return a Boolean statement which allows them to be used in a conditional statement.
14) Does JDBC support stored procedures?
Stored procedures form a logical unit which executes certain statements in a predefined format or logic. Most of the DBMS support Stored procedures. A fair amount of variation in the syntax is present. A stored procedure can be invoked from JDBC.
15) Explain about Join?
Join is very important in JDBC. It joins two or more tables in the database by the commonly shared values present in them. Tables should be created and they should have a common value present in them for joining. You can precede the column name with the table name which gets you your desired table.
16) Explain about the main method?
For a class to get executed it should contain static public main method. This method also allows you to invoke other methods. When we define classes we not only want other classes to follow it but it should also execute. This is the centralized idea behind main method.
17) Explain about the Try Block?
Try and Catch blocks are primarily used for handling exception. Java wants a mechanism which can handle when an exception is thrown. Try block spots the exception and hands it over to catch block which process the exception and deals with it appropriately. Try block contains classes and logic inside it.
JDBC defines the connectivity pattern between the client and his route to database. Querying and updating method is provided in JDBC. It is primarily based on RelationalDBMS. It is a part of the Java Standard edition. JDBC classes are present in the Java package.
2) Explain about multiple implementations and drive manager?
JDBC is liberal in the usage and representation of multiple implementations in the same application. It provides a feature by which it allows loading of correct Java packages and registering them with Driver manager. A Driver manager is primarily responsible for creating JDBC connections.
3) What are the different types of JDBC drivers?
There are many implementations of JDBC drivers out of which some types are: -
• Drivers which implement JDBC API as mapping to another data access API.
• Drivers written in Java programming and in native code.
• Drivers which communicate with middle ware server using database independent protocol.
• Drivers which implement network protocol and are present in pure Java.
4) What are the different classes through which JDBC represents statements?
Statements are represented in JDBC using one of these classes: -
• Statement
• PreparedStatement
• CallableStatement
Stored procedures can also be invoked through JDBC.
5) Explain what should be done when a SQL exception is raised?
SQL exception is raised when a data base operation fails. The chances of recovering the lost database is meager apart from logging the file with much detail one can translate the SQL exception into application domain which will eventually result in a roll back which may solve the problem to a certain extent.
6) Explain about the drive manager class working?
To manager a set of drivers available to JDBC a driver manager class needs to work with Driver interface. When a client requests for a specific connection by providing a URL it is the responsibility of driver manager to find a driver which can recognize that particular URL and that URL should be used for connecting to a database.
7) Why do you use a data source object for a connection?
Data source object uses a logical name for a data source and this feature increases application portability. This removes the necessity of supplying information to each and every driver. Data source can be configured manually or automatically.
8) State the three different ways in which you can create a table?
Tables can be created in three different ways they are: -
1) Using IDE graphical interface
2) Using ANT framework
3) JDBC SQL written into a framework.
9) Explain the process of creating tables using NetBeans IDE?
Although Vendors provide specific GUI which can create tables, they can also be created using NetBeans IDE. Databases can be created either through pull-down menu or by right clicking database. Clicking on the Tables icon select BBB create table. Changes can be made to that specific table by right clicking on them.
10) How do you determine the sensitivity of the ResultSet object?
Sensitivity of ResultSet object is determined in three ways they are: -
1) TYPE_FORWARD_ONLY: -It contains rows which satisfied the query. These rows are satisfied either at the time of execution or as the rows are retrieved.
2) TYPE_SCROLL_INSENSITIVE: - Here the cursor can move forward backward or to an absolute position.
3) TYPE_SCROLL_SENSITIVE: - This works in the same way as the Scroll insensitive.
11) Explain about column name and getter method?
Getter methods have column names as inputs and they are case sensitive. In case a column has more than one name or similar names it considers the value of the first name and it returns search for the first name only. If columns are not explicitly named then it searches with the numbering.
12) Give an example for getXXX method?
This command retrieves the value present in each column. Consider you created a table with name KAR_NAME the first column present in each row stores a value of SQL type VARCHAR. Usual method which can be used for retrieving a value of SQL type varchar or (variable character) is getstring.
13) What are the methods which can verify about the cursor particular position?
In addition to these methods there are other four methods which let you verify the position of the cursor they are isFirst, isLast, isBeforeFirst, isAfterLast. All these methods return a Boolean statement which allows them to be used in a conditional statement.
14) Does JDBC support stored procedures?
Stored procedures form a logical unit which executes certain statements in a predefined format or logic. Most of the DBMS support Stored procedures. A fair amount of variation in the syntax is present. A stored procedure can be invoked from JDBC.
15) Explain about Join?
Join is very important in JDBC. It joins two or more tables in the database by the commonly shared values present in them. Tables should be created and they should have a common value present in them for joining. You can precede the column name with the table name which gets you your desired table.
16) Explain about the main method?
For a class to get executed it should contain static public main method. This method also allows you to invoke other methods. When we define classes we not only want other classes to follow it but it should also execute. This is the centralized idea behind main method.
17) Explain about the Try Block?
Try and Catch blocks are primarily used for handling exception. Java wants a mechanism which can handle when an exception is thrown. Try block spots the exception and hands it over to catch block which process the exception and deals with it appropriately. Try block contains classes and logic inside it.
Subscribe to:
Posts (Atom)