There are object oriented and object based languages differ in few properties, object oriented language is having support for all object oriented concepts like class, object, inheritance,polymorphism,dynamic binding,message passing etc, but object based languages doesn't support properties inheritance and dynamic binding (dynamic binding is closely related to inheritance), for example, C++, Simula, Small talk,Eiffel, Java all are object oriented languages, visual basic 6.0 can be considered as an object based language which support class and object but not inheritance and dynamic binding, but current versions of visual basic is object oriented because they support all the above mentioned features. Ada is another example for object based language. Some authors count C++ as not object oriented, instead it as extended conventional languages, similarly the same case for Objective C, Object pascal, Turbo pascal etc.
Experience Note:-
A similar question was asked on NIC (National Informatics Center), India recruitment test. The question was to find one in the 4 choices that is object based; choices were C++, Java, Visual Basic etc, like an odd man out question.
Showing posts with label nic recruitment test. Show all posts
Showing posts with label nic recruitment test. Show all posts
Sunday, November 28, 2010
Object based and Object oriented Languages
Labels:
c++,
java,
nic recruitment test,
object based,
object oriented
Friend of a friend and Parent's friend in C++
If A is a friend class of B and B is a friend of C then can we say A and C are friends?
No. If there will be no friend relation between those classes, if class A is a friend of B then A can access the data members(including private) of class B, and if class B is a friend of class C, similarly class C can have access to class B's data members, but can't access the member of class A which is already a friend of B. i.e can't access friend of a friend's member. It is the same concept that If Alice is bob's friend and if Bob is your friend then it will not be always true that Alice is your friend too(hint:- or even if Alice is your friend too, you will not have access to her private properties, that bob has access to).

class A
{
....
....
};
class B
{
.....
.....
friend class A;
};
class C
{
......
......
friend class B;
};
Friend of Parent
Similarly it is same in the case of inheritance too. If class A is a parent of class B and class F is friend of class A (Parent of B) then class F have access to class A's private attributes members, but not class B's. It is same concept that if your parent has a friend he have some right to access to your parent's properties, it doesn't mean that he has the same right to access your properties too.

class A
{
....
....
friend class F;
};
class B : public/private/protected A
{
};
Experience Note:-
A similar question was asked during NIC(National Informatics Center), India Recruitment Test. The NIC test was purely technical and there was questions from almost all areas of computer science including Data structure, Computer networks, Computer architecture, C Programming, C++ programming, Compiler design and Theory of computation (Automata and computer languages), Database systems, Software Engineering, Cryptography and Network Security, Digital logic and basic electronics, awareness about current software systems available and few Linux commands based questions for example
which is not a relational database in the given four choices (choices like Reflex, mysql, fourth dimension, oracle)
which of the following is an object based language
which of the following cant be used to make web pages etc (java services, jsp, asp etc)
No. If there will be no friend relation between those classes, if class A is a friend of B then A can access the data members(including private) of class B, and if class B is a friend of class C, similarly class C can have access to class B's data members, but can't access the member of class A which is already a friend of B. i.e can't access friend of a friend's member. It is the same concept that If Alice is bob's friend and if Bob is your friend then it will not be always true that Alice is your friend too(hint:- or even if Alice is your friend too, you will not have access to her private properties, that bob has access to).
class A
{
....
....
};
class B
{
.....
.....
friend class A;
};
class C
{
......
......
friend class B;
};
Friend of Parent
Similarly it is same in the case of inheritance too. If class A is a parent of class B and class F is friend of class A (Parent of B) then class F have access to class A's private attributes members, but not class B's. It is same concept that if your parent has a friend he have some right to access to your parent's properties, it doesn't mean that he has the same right to access your properties too.
class A
{
....
....
friend class F;
};
class B : public/private/protected A
{
};
Experience Note:-
A similar question was asked during NIC(National Informatics Center), India Recruitment Test. The NIC test was purely technical and there was questions from almost all areas of computer science including Data structure, Computer networks, Computer architecture, C Programming, C++ programming, Compiler design and Theory of computation (Automata and computer languages), Database systems, Software Engineering, Cryptography and Network Security, Digital logic and basic electronics, awareness about current software systems available and few Linux commands based questions for example
which is not a relational database in the given four choices (choices like Reflex, mysql, fourth dimension, oracle)
which of the following is an object based language
which of the following cant be used to make web pages etc (java services, jsp, asp etc)
Labels:
c++,
friend class,
nic recruitment test,
private members
Subscribe to:
Posts (Atom)