Oops 2marks
Oops 2marks
Oops 2marks
Engineering College
CS 2311- OBJECT ORIENTED PROGRAMMING -Question Bank
Kavaraipettai -601 206
UNIT-I
Object oriented programming concepts objects-classes- methods and messagesabstraction and encapsulation-inheritanceabstract classespolymorphism. Introduction to C++- objects-classes-constructors and destructors.
Possible Part-B questions: 1. i) Define OOP.Explain object-oriented programming Features & Concepts in detail. (12) i) Write the Characteristics & Drawbacks of procedure oriented language POP. (4) 2. i) Define polymorphism. Explain the types of polymorphism with example. (8) ii) Write the Characteristics & Drawbacks of procedure oriented language POP. (4) iii)Write the difference between procedure oriented language (POP)& object oriented Language(OOP) (4) iii) State the merits and demerits of object oriented methodology. (6) 3. i) How object are used in C++ program? Write a C++ program for the employee class. ii) Write a C++ program to explain the concept of array of objects. Use student class. 4. i) Define inline function. List the situation where the inline function may not work? (4) ii) Write a C++ program to explain the concept of inline function. (4) iii) What is function overloading? & Explain with a suitable C++ program.(8) 5. i) Define & explain the following with a suitable C++ program. a. Local class(4) b. Nested class(4) ii) Define friend function. Explain with a suitable C++ program. (8) 6. i) What is static data member? Write a C++ program to explain the concept of static data member.(8) ii) ) What is static member function? a C++ program to explain the concept of static member function .(8) 7. i) Define Parameterized constructor .Explain the Parameterized constructor concepts with suitable C++ program. ii) Define Copy constructor Explain the Copy constructor concepts with suitable C++ program. 8. i) Define Multiple constructor Explain the Multiple constructor concepts with suitable C++ program. ii) How the Constructor with dynamic allocation is occur in C++? Explain with suitable example program. 9. i)What is Destructor? Write the difference between destructor & constructor. Explain the order of destructor to be called with suitable C++ program. ii) How the constructors can be overloaded? Illustrate with an example. 10. What is the role of new & delete in C++ program? Write a C++ program for String concatenation using dynamic memory allocation concept.
UNIT-II
Operator overloading - friend functions- type conversions- templates - Inheritance virtual functions- runtime polymorphism. Possible Part-B questions: 1. i) Write a C++ to overlaod the Preincrement(++)& Post Decrement (--) unary operator using member function. ii Write a C++ to overlaod the Preincrement(++)& Post Decrement (--) unary operator using friend function. 2. i) ) Write a C++ to overlaod the for arithmetic operators (+,-) for two complex numeber using member function. ii) Write a C++ to overlaod the for arithmetic operators (*,/) for two complex numeber using friend function. 3. Write a program to overload function. the istream operator (>>)&ostream operator (<< )using friend
4. What is type conversion? Explain the various types of type conversion with suitable C++ program. 5. i) Define function template Implement a generic bubble sort template function for the following inputs. A. 9,2,7,4,5,6,8,3,1 B. a,s,d,t,f,e,g,c,b C. 7.7,1.1,4.4,3.3,8.8,2.2,6.6,9.9,5.5 ii) Write a function template to swap a two interger,float,double datas 6. i) How the function templates can be overloaded. Write a C++ program.
UNIT-III
Exception handling - Streams and formatted I/O file handling namespaces String Objects - standard template library
Possible Part-B questions: 1. What is exception handling? Explain the components of exception handling with neat sketch
ii) Explain the different types of streams & various formatted I/O on C++. (10)
4. i) What are manipulators? Explain the various manipulators with example. (8)
ii) How can you design an own manipulators? Write a program. (8)
5. Explain the file handling techniques in C++ programming. 6. Using tellp (), tellg ( ) &seekg (), seekp () write a C++ program to access the data from a file
by randomly.
7. Define namespace. Write a program for the following:
a. How the namespace can be used in functions? Write a C++ program. b. How the namespace can be used in Class? Write a C++ program.
8. Explain the various functions supported by the String class in C++. Explain with suitable C+
+ programs.
UNIT-IV
Introduction to JAVA , bytecode, virtual machines objects classes Javadoc packages Arrays - Strings
Possible Part-B questions: 1. i)What is JVM? Explain the JVM process in detail with neat sketch. ii) Explain the java features in detail (or) Explain the java BUZZ words in details. 2. i) Write a java program to implement the addition of matrix using single dimensional array. ii) Write a java program to implement the multiplication of matrix using two dimensional arrays 3. write a java program for the following : i. ii. iii. Find the maximum of given array. (Or) Find the minimum of given array. Sort the given array elements in ascending order (Or) Sort the given array elements in descending order. To Copy one array elements to another array.
4. i) Write short notes on the various string methods in Java ii) Write a java program to perform all string operations using String class. 5. i) Define package. What are the types of packages? Write the steps to create a package in java. ii) Write a program to define a user defined package in java.
UNIT-V
Inheritance interfaces and inner classes - exception handling threads - Streams and I/O
Possible Part-B questions: 1. i) Explain the various types of inheritance in java ii) Write a java program for single inheritance. (Example1: Room->Bedroom, Example2: Box->Box3D, Example3: Student -> Calculate ) 2. i) Why multiple inheritance is not possible in java? Justify it. How it is possible to create multiple inheritance in java. (8) ii) Write a java program to explain the concept of interface in detail. 3. Explain about exception handling in java with an example& List the different types of java exception. 4. i) Write a java to program to divide 2 numbers & raise exception when dividing by zero. (By Predefined Exception) ii) Write a java to program to add 2 integers & raise exception when any other character except no (0-9) is given as input. (By User-defined Exception) 5. i) Differentiate thread from process. Explain the thread life cycle in detail with neat sketch ii) Write a java program to explain the concept of multithreading by Using the various thread methods. 6. i) Short notes on various I/O streams in java. ii) Short notes on inner class. Write a simple java program for inner class.
UNIT- I PART- A
1. Define OOP. OOP is a method of implementation in which programs are organized as co-operative collections of objects, each of which represents an instance of some class and whose classes are all members of hierarchy of classes united through the property called inheritance. 2. What are the characteristics of procedure oriented language? The following are the characteristics of procedure-oriented language Emphasis is on doing things (algorithms). large programs are divided into smaller program known as functions most of the functions share the global data Data move openly around the system from function to function. Functions transform data from one form to another. It employs TOP-DOWN approach in a program design.
3. List the drawbacks of procedure-oriented language? The following are the drawbacks of procedure-oriented language, More concentration on function not for data. In large program its difficult to find what data is used by which program It does not meet the real world problems well. Less data security. In case the need arises to modify the format of the data, all the functions access The data also need to be modified. This makes over head. 4. What the characteristics are of object oriented language?
5. List the object oriented programming concepts. The following are the object oriented programming concepts CLASS: The collection of similar object is known as class. The entire set of data and code of an object can be made a user-defined data type with the help of a class. Once a class has been defined, we can create any number of objects belonging to the classes. Classes are user-defined data types. Example: Fruit mango; OBJECT: Objects are basic run-time entities in an object-oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program has to handle. Each object has the data and code to manipulate the data and theses objects interact with each other. Fruit mango; ENCAPSULATION: The wrapping up of data and functions into a single unit is known as encapsulation. Example: Medical capsule. DATA ABSTRACTION: It refers to the act of representing the essential features without including the background details. The insulation of data from direct access by the program is called as data hiding or information // here mango is the object of the fruit class 7. Define the following with an example. a) ENCAPSULATION b) DATA ABSTRACTION. // here fruit is the class Objects Classes Data abstraction Encapsulation Inheritance Polymorphism Dynamic binding Message passing
cout<< welcome to oop; int a=2; int c=a<<2; Here with respect to cout << acts as an insertion operator with respect to a<<2 << acts as a left shift operator.
The types of polymorphism:
Polymorphism
10. Define dynamic binding. Binding refers to the linking of a procedure to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at the run-time 11. List the applications of OOP. The following are the applications: Real-time systems. Simulation and modeling. Object-oriented databases. AI and expert systems. 12. What are the merits of OOP? The following are the merits of OOP: Code reusability reduced maintenance. Improved reliability & flexibility. Real world modeling. 13. What are the demerits of OOP? The following are the demerits of OOP: The runtime cost of dynamic binding is the major disadvantage of OOP. reduced maintenance. Improved reliability & flexibility.
14. What do you mean by object-based programming? Object based programming is the style of programming that primarily supports encapsulation and object identity. Features supported: Data encapsulation Automatic initialization and clear up of objects Data hiding and access methods. 15. How does object oriented programming differs from object based programming? Object based programming is the style of programming that primarily supports encapsulation and object identity .whereas
17. Define token. What are the types of token? The smallest individual units in a program are known as tokens. C++ has the following tokens, Keyword Identifiers Constants Strings Operator
The two normal uses of void are To specify the return type of the function when it is not returning a value To indicate an empty argument list to a function 19. Define an enumeration data type. An enumerated data type is a user defined data type that provides a way for attaching names to numbers thereby increasing comprehensibility of the code. The enum keyword is used which automatically enumerates a list of words by assigning them values 0, 1, 2 E.g.) enum weeks {mon, tues, wed,thus,fri,sat,sun};
20. Define constant pointer and pointer to a constant.
The constant pointer concept does not allow us to modify the value initialized to the pointer. e.g.) char * const ptr = GOOD; The pointer to a constant concept doesnt allow us to modify the address of the pointer.
Reference is a mechanism to make an alias of a variable. When a referencing variable is made to refer to a referred variable, both variables becomes alias of each other. Changing the value of either of them, changes the values of the both. Syntax : datatype &reference_variable_name = variable_name; Example: int y; int &x = y; Now the value of x and y will be the same and also if any one of the value is changed the change will be reflected in the other variable. y =10; Now x is also 10. x = 20; Now y is also 20. y = x + 10; Now x and y is 30 22. What are Data types available in C++?
Operators are the symbols which represent various computation performed on various data item.
24. What is the use of Scope Resolution operator? The scope resolution operator: : is used to access global variable in the inner block. When global and local variable are identical name the scope resolution operator will help to access the global variable in the inner block. This cannot be done in C programming. This operator will read only the global variable. Example: int x=10; int main() { int x=100; { int x=1000; cout<<"\n"<<x; // This statement will display 1000 cout<<"\n"<<::x; // This statement will display 10 } cout<<"\n"<<x; //This statement will display 100 cout<<"\n"<<::x; //This statement will display 10 return 0; } 25. List the C++ special operators. :: ::* Scope resolution operator Pointer-to-member declaration operator
26. What are the memory management operators in C++? new : It is used to allocate the memory. Also known as Memory allocation operator. Syntax: pointer-variable = new data type; delete : It is used to de allocate the memory. Also known as Memory release operator. Syntax: delete pointer-variable; Program: void main() { int *a; a= new int(21); cout<<the value of *a = <<*a; delete a; } 27. Write the difference between structure & class ; Structure Strucutre Class
It is a collection of disimilar data types. The default access modifer for members (data and methods ) is public. Example:
struct stud { Public: int a; int b; };
It is a collection of similar type of object. The default access modifer for members (data and methods ) is private. Example:
class stud { Private: };
int a; int b;
28. Write the difference and Advantages of new versus malloc (). Syntax of new is similar than malloc (). No size, no void pointer & no casting are required for new operator.
33. What is a default argument? Default arguments assign a default value to the parameter, which does not have matching argument in the function call. Default values are specified when the function is declared. Example :
36. Define friend function. Give an example. A function which is not member function of a class but is given special permission to access the private variable of the class is known as friend function. Friend function is preceded by the keyword friend. Syntax: friend return- type function_name(list of arguments ); Example: friend float mean( sample s); 37. Define friend class. Give an example. A class that is made a friend of another class is known as friend class. Example: Class x { Private: int fun(); }; Class y { friend int x :: fun ( );
41. Define pointers to member. It is possible to take the address of a member of a class and assign it to a pointer. The address of a member can be obtained by applying the operator &to a fully qualified class member name. A class member pointer can be declared using the operator::*with the class name. Eg:
Dynamic allocation may be required when an object is defined. Object may need to be set to special values. When inheritance is in effect, if a base class has a constructor, a derived class must also have one to initialize itself. 48. List the rules for defining constructor. (Or) what are the characteristics of a constructor? A constructor must have the same name as the class itself. A Constructor has no return type, even void. Constructor cannot be a virtual function. Constructor should be defined in Public only. Constructor can be overloaded. An Address of a constructor cannot be obtained; hence we cannot have a function pointer, pointing to a constructor. We can define constructors as private, but that would disable us from defining objects using those constructors. Therefore, unless normal definition of the object is not restricted, the constructors should be defined public. 49. How the constructor function is invoked? (Or) what are the 2 methods are used to invoke the constructor function. There are 2 methods are used to invoke the constructor function. By calling the constructor function Explicitly. By calling the constructor function Implicitly.
Default constructor Parameterized constructor. Copy constructor Multiple constructors. Explicit Constructor
51. Define default constructor. Give an example. A default constructor is a constructor with no argument or with all default argument. It is also called a 0-argument constructor. There are two types of constructor. 1. Complier Defined Default Constructor 2. User Defined Default Constructor EXAMPLE: class Sample { public: Sample () { } }; 52. What is parameterized constructor? Give an example. constructor with arguments is called parameterized constructor Eg; Class integer { int m,n; public: integer(int x,int y) { m=x; n=y; }
57.
61. Write the difference between constructor and destructor. CONSTRUCTOR Its used to construct the object It can be called automatically when an object comes into existence The constructor function is called every time an object is created. It is the function invoked first before calling any function It can be o overloaded It takes any number of argument A class can have multiple constructor DESTRUCTOR Its used to destroy the object It is called when an object goes out of scope. The destructor function is called every time the program exits a block. It is the function called at last It cannot be overloaded It takes no arguments. Only one destructor function for a class is possible.
7. Write the syntax to define the operator function. return_type classname :: operator operator symbol(argument) { .. statements; } return_type is the data type returned by the function class name - is the name of the class operator is the keyword operator symbol is the symbol of the operator which is being overloaded or defined for new functionality :: - is the scope resolution operator which is used to use the function definition outside the class.
10. Explain basic to class type conversion with an example. Conversion from basic data type to class type can be done in destination class.Using constructors does it. Constructor takes a single argument whose type is to be converted. Eg: Converting int type to class type class time { int hrs,mins; public: . Time ( int t) //constructor { hours= t/60 ; //t in minutes mins =t % 60;
12. What is the need of template functions in C++? What are their advantages? Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one. This is effectively a Turing-complete language. Templates are of great utility to programmers in C++, especially when combined with multiple inheritance and operator overloading. The C++ Standard Library provides many useful functions within a framework of connected templates. 13. What is generic programming? Generic programming is an approach where generic types are used as parameters in algorithms so that they work for a variety of suitable data types and data structures. 14. Define template.
Polymorphism Polymorphism is achieved by function overloading and operator overloading. Polymorphism means use the same function or operator for different purpose without changing their basic meaning. Depending upon the data type passed to them they perform different operations, where function or operator should be defined for each data type. Polymorphism is used to reduce software complexity.
Template Template is achieved by function template and class template. Template means use the same function or class for different purpose without changing their basic meaning where function or class should be defined only once.
16. Define function template. Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type. Syntax: template<typename template datatype> Returntype function name(list of arguments) { .//.} 17. Define class template. A class is defined also to be declared to operate on different data type such classes are called class templates. Syntax: template<typename template datatype> class classname { } Syntax for object creation using class template: Classname<datatype> objectname1;
23. What is the difference between template function and template class? Template function Template class Data type is automatically deduced from the function call. No need to pass the type of data separately Only the actual function is generated Need to pass the type of data for the creation of object. Actual class and its object are generated simultaneously.
24. Define inheritance. List the types of inheritance. The process of creating a new class from an already existing class is known as inheritance. The new class contains all attributes of the old class in addition to some of its own attributes. It can also override some of the features of the old class. Class A Base Class (Or) Super Class (Or) Parent Class Derived Class (Or) Sub Class (Or) Child Class Class B The following are the types of inheritance. vii. Single inheritance
25. What are the advantages of inheritance? The following are the advantages of inheritance: i. We can extend the functionality of an existing class. ii. It offers reusability of code. iii. No need to create objects from scratch. iv. C++ provides us mapping of real world hierarchy in our program. v. Reusable software components can be developed. vi. It reduces software development time and cost considerably. 26. What is Is-a relationship and has a relationship? Is-a relationship: If class B is derived from the class A, then we can say that class B is a kind of A. Since class B has all the properties of A in addition to the features of its own. Example: CAR sports car is a type of car
has-a relationship:
SPORTS CAR If a class contains another class then the relationship is a part of relationship. The Part of relationship is also called as has a relationship. Example: CAR Engine is a part of car
Engine
27. What are the access speicifiers? Write syntax to derive a class. The following are the type of access speicifiers in C++: a) Public: b) Private: c) Protected: Syntax for Defining a Derived Class:
Class derived_class_name : visibility_mode base_class_name { ----- --- ----- -------- --- ----- ---}
Derived Class
The class A is base class to the class B (i.e.,) class B is derived from class A. Syntax: class Base_class_name { //Data members //Member functions }; class Derived_class_name:visibility_mode base_class_name { //Data members //Member functions Example: Class Person { -------}; Class Student: public Person { ---------};
};
};
29. Define multiple inheritances. Give an example. Definition: The process of deriving a class from several base classes is known as multiple inheritance. Base Class 1 A B Base Class 2
Derived Class
};
36. Define multilevel inheritances. Give an example. The derivation of a class from another derived class is known as multilevel inheritance. Base Class A Derived Class (Intermediate Base Class)
C Syntax: class Base_class_name { //Body of base class } class Derived_class1_name:visibility_mode base_class_name { //Body of derived class1 }; class Derived_class2_name:visibility_mode derived_class1_name { //Body of derived class2 };
Derived Class Example: Class Person { -------}; Class Student: public Person { -------}; Class Exam: public Student
B
Syntax:
C
Example: Class Car { -------}; Class SportsCar: public Car { -------}; Class PassenegerCar: public Car { --------};
class Base_class_name { //Body of base class } class Derived_class1_name:visibility_mode base_class_name { //Body of derived class1 }; class Derived_class2_name:visibility_mode base_class_name { //Body of derived class2 }; 30. Define hybrid inheritance. Give an example. Definition:
38. Define hybrid inheritance. The derivation of a class involving more than one form of inheritance is known as hybrid inheritance.
B B D
Syntax: class Base_class1_name { ---------------} class Derived_class1_name:visibility_mode base_class_name1 { ------------------}; class Base_class2_name { --------------------} class Derived_class2_name:visibility_mode derived_class1_name, visibility_mode Base_class2_name { -----------------------};
Example: Class Person { -------}; Class Student: public Person { -------}; Class Exam: public Student { -------}; Class Sports { -------}; Class Result: public Exam, public Sports { -------};
31. Define multi path inheritance. Give an example. Derivation of class from other derived classes, which are derived from the same base class is called multipath inheritance. A class Base_class_name { ---------------C B } Syntax: class Derived_class1_name:visibility_mode base_class_name D { ------------------}; class Derived_class2_name:visibility_mode base_class_name { -----------------------}; class Derived_class3_name:visibility_mode Derived_class1_name, visibility_mode Derived_class2_name, { -----------------------};
32. What is the public derivation? List the constraints of the public derivation. Syntax: class Base { //Body of the base class } class Derived : public Base { //Body of Derived class }; This derivation is known as public derivation. The member of base class are now treated as, 1. The public member of base class is treated as public member of the derived class. 2. The private member of base class is not inherited. 3. The protected member of base class is protected member of the derived class. 33. What is the private derivation? List the constraints of the private derivation. The member of base class are now treated as, 1. The public member of base class is treated as private member of the derived class. 2. The private member of base class is not inherited. 3. The protected member of base class is private member in the derived class. Syntax: class Base { //Body of the base class } class Derived : private { //Body of Derived class };
class Base { //Body of the base class } class Derived : protected Base { //Body of Derived class }; This derivation is known as protected derivation. The base class members are treated as follows: 1. The public member of base class is treated as protected member of the derived class. 2. The private member of base class is not inherited. 3. The protected member of base class is treated as protected member in the derived class. 35. What is virtual base class? Give an example. A class which is defined as virtual at the time of inheriting it. The compiler takes a note of it and when its inherited further using multiple inheritances it ensures that only one copy of the sub object of the virtual inherited class exists in the derived class. 36. Define abstract class. Give an example. The classes without any objects are known as abstract class or abstract base class. It contains at least one pure virtual function. Example: class sample { Public: void virtual show( )=0; }; 37. Compare compile time polymorphism with run time polymorphism? Compile time polymorphism: The compiler while compiling the program resolves the function call or the operator call. This is known as compile time or static polymorphism. It is achieved by operator & function overloading. Run time polymorphism: Resolving function call at run time is known as run time or dynamic binding. Its achieved by virtual functions. 38. What is this pointer?
UNIT-III PART- A
1. What are Exceptions? What are the two types of exceptions? Exceptions, which occur during the program execution, due to some fault in the input data. Exceptions are classifieds into
6. What is object destroy problem? How can exception handling help them? A destructor is needed for an object which is created with dynamic constructor to smoothly return the resources consumed by it and to close connections. The exit or abort functions do not call the destructor of an object so the objects are not destroyed properly. This is called object destroy problem. Exception handling mechanism may be used here to call the destructor automatically. 7. What is the importance of throwing objects rather than Built-in type values?
Its best for developing a library for a large project. Its important that the library functions throwing exceptions must be standardized. 10. List out some of the error handling functions eof()-Returns true if end-of-file is encountered fail()-Returns true when an input or output operation has failed bad()-Returns true if invalid operation is attempted by or any uncoverable error has occurred good()-Returns true if no error has occurred 11. List out the tasks to be performed for error handling code 1) Detect the problem causing exception (Hit the exception) 2) Inform that an error has occurred (Throw the exception) 3) Receive the error information (Catch the exception) 4) Take corrective actions (Handle the exceptions) 12.Draw the Exception handling model? Try block
Invoke function having throw block Throw block If(failure) exception Throw object; exception
Catch block Catches all exceptions thrown from within try block or by function invoked within a try block
The mechanism suggests that Exception Handling code must perform the following 1. Detect the problem causing exception (hit exception) 2. Inform that an error has occurred (thrown an exception) 3. Receive the error into (catch the exception) 4. Take corrective actions (Handle the exception) 13. Write the syntax of try construct The try keyword defines a boundary within which an exception can occur.A block of code in which an exception can occur must be prefixed by the keyword try.Following the try keyword is a block of code enclosed by braces.This indicates that the program is prepared to test for the existence of exceptions.
Keyword try
Keyword
throw T; 16. Write the steps to be performed when an exception is raised 1) The program searches for a matching handler 2) If a handler is found, the stack is unwound to that point 3) Program control is transferred to the handler 4) If no handler is found, the program will invoke the terminate () function. If no exceptions are thrown, the program executes in the normal fashion 17. Write the syntax of specifying a list of exceptions
Function definition
FunctionSpecification throw(type id1,type id2,) { //Function body raising exceptions if error occurs } 18. Write the syntax of catch all construct Catch() { //actions for handling an exception } 19. Write the functions to handle uncaught exceptions 1) terminate () - It is invoked when an exception is raised and the handler is not found.
istream
streambuf
istream_withass ign
iostream_withassig n
ostream_withas sign
25) List out some of the formatted I/O operations C++ supports a number of feature that could be used for formatting the output.These features include a)ios stream class member functions and flags b)Standard manipulators c)User defined manipulators 26) List some of the ios functions a)width() b)precision() c)fill() d)setf() e)unsetf() 27) List some of the non-parameterized manipulators a)dec b)hex c)oct d)es e)endl f)ends g)flush 28) What is custom/user-defined manipulators The users can design their own manipulators to control the appearance of the output 29)Write the syntax of creating a custom manipulator. Ostream & manipulator(ostream & output, arguments_if_any) { (manipulator code)
istream
streambuf
ostream
iostream
filebuf
ifstream
fstream
ofstream
fstreambas e 34) What are the functions that the file stream class provides? a)seekg()-Moves get pointer to a specified location b)seekp()-Moves put pointer to a specified location c)tellg()-Gives the current position of the get pointer d)tellp()-Gives the current position of the put pointer 35) What is a file? A file is a collection of related information defined by its creator. Files represent programs (both source and object forms) and data.Data may be numeric,alphabetic, or alphanumeric.Files may be freeform,such as text files,or may be rigidly formatted. 36) List some of the file modes 1)ios::in 2)ios::out 3)ios::ate 4)ios::app 5)ios::trunk 6)ios::nocreate 7)ios::noreplace 8)ios::binary 37) What is meant by namespace?
Element0
Element1
Element2
.. Last Element
47) What are the types of sequence containers? The STL provides three types of sequence containers 1) Vector 2) List 3) Deque 48) What is meant by Associative Containers? Associative containers are designed to support direct access to elements using keys. 49) What are the types of Associative containers? The STL provides three types of associative containers 1) Set 2) Multiset 3) Map 4) Multimap 50) What is meant by Derived Containers? The derived containers do not support iterators and therefore we cannot use them for data manipulation. They support two member functions pop() and push() for implementing deleting and inserting operations. 51) What are the types of derived containers The STL provides three types of derived containers 1) Stack 2) Queue 3) Priority queue 52) What is meant by vector? The vector stores elements in contiguous memory locations and enables direct access to any element using the subscript operator[].A vector can change its size dynamically and therefore allocates memory as needed at run time.
Key 1
Value 1
Key 2
Value 2
Key N
Value N
55) Write the member functions of the map class 1) begin () 2) clear() 3) empty() 4) end() 5) erase() 6) find() 7) insert() 8) size() 9) swap()
UNIT-IV PART- A
1. What is Java? Java is a high-level, third generation programming language, like C, FORTRAN, Smalltalk, Perl, and many others. You can use Java to write computer applications that crunch
28. List the Classes that represent strings in java and differentiate them 1. String 2. StringBuffer String class String objects are immutable( not subjected to change) Creates strings of fixed length 9. What is package? Package is a collection of related classes and interfaces. It is also defined as putting classes together. 30. What are the package of Java? 1. Java API Packages 2. User Defined Packages 31. Write about API Packages? StringBuffer class StringBuffer objects are mutable(subjected to change) Creates string of flexible length
33. Why Java use Unicode? Java use Unicode to represent a character. Unicode defines a fully international character set that can represent all of the characters found in all human languages. 34. What is Classpath? The Classpath is an argument we can set either on the command-line, or through an environment variable that tells the Java Virtual Machine where to look for user defined classes and packages when running Java programs. 35. What is the Significance of class path. Java interpreter uses an environment variable classpath, to determine the path to look for user defined classes. 36. What are Nested classes? A nested class is a class defined as a member of another class. There are two types of nested class. 1. Static nested class. 2. Non static nested class ( inner class) The scope of nested class is bounded by the scope of its enclosing class. The nested class has access to the members of its enclosing class including private members. Example:
Class outer { Static Class inner
37. What is meant by inner class? A class which is defined within another class without static keyword is called inner class. There are two types of inner class. 1. Local class. 2. anonymous class .
Example: Class outer { Class inner { .. } }
38. What is meant by Wrapper Classes? Corresponding to all the primitive data types java defines a set of classes referred as wrapper classes, which serves as class versions of the fundamental data types and named similar to the data types. 39. Define Instance of Operator in java? The instance of operator is a keyword, which is used to find out whether the object belongs to which class instance or not. Note that the instance of operator will cause a compile time error if it is used to check a class when there is no inheritance. 40. Mention some of the important classes present in java.net package. 1. The inetaddress class 2. URL class 3. Socket Class 4. The contenthandler class
UNIT-V PART- A
1. What do you mean by inheritance?
17. Define Dead Lock. A Dead Lock is defined as a special type of error that relates specifically to multitasking is dead lock, which occurs when two threads have a circular dependency on a pair of synchronized objects(i.e.,Deadlock occurs when 2 or more threads are waiting for resources that they cant get.). 18. How Threads are created in Java? Theads are created in two ways, i. extending the Thread class ii. implementing Runnable interface. 19. What is Thread pool? A Thread pool is a managed collection of threads that are available to perform tasks. Thread pools usually provide, i. Improved performance when executing large numbers of tasks due to reduced per-task invocation overhead. ii. A means of bounding the resources, including threads, consumed when executing a collection of tasks. 20. What do you mean by Thread Scheduling?
Execution of multiple threads on a single CPU in some order is called Thread scheduling. The Java runtime environment supports a very simple, deterministic scheduling algorithm called fixed-priority scheduling. This algorithm schedules threads on the basis of their priority relative to other Runnable threads. 21. What is the use of Data input and output streams? Data input and output Streams are used to read or write primitive data types in a machineindependent format. 22. What is the use of Buffered Streams?