YouTube Icon

Interview Questions.

Top 100+ C++, C, Oracle Interview Questions And Answers - May 28, 2020

fluid

Top 100+ C++, C, Oracle Interview Questions And Answers

Question 1. What Is Oracle Database?

Answer :

Oracle Database is a relational database control device (RDBMS) that is used to save and retrieve the huge amounts of data. Oracle Database had bodily and logical systems. Logical structures and bodily systems are separated from every different

Question 2. Explain Oracle Grid Architecture?

Answer :

Grid computing is a statistics technology structure that provides decrease price organization statistics systems. Using grid computing, unbiased hardware, and software components may be connected and rejoined on demand to satisfy the changing desires of companies. It additionally enables the use of smaller person hardware components.

Oracle 9i Interview Questions
Question three. What Is The Difference Between Large Dedicated Server And Oracle Grid?

Answer :

Large dedicated server:

It has highly-priced costly additives.
High incremental fees.
It has single factor of failure.
Enterprise carrier at higher value.
Oracle Grid:

It has low price modular additives.
Low incremental prices.
It has no unmarried point of failure.
Enterprise service at low price.
Question 4. What Are The Computing Components Of Oracle Grid?

Answer :

The computing componenets of oracle grid are:

Oracle Enterprise Manager and Grid Control
Oracle 10g Database and Real Application Clusters.
ASM Storage Grid.
Oracle 9i Tutorial
Question 5. What Is Server Virtualization?

Answer :

Oracle Real Application Clusters 10g (RAC) enables a single database to run throughout a couple of clustered nodes in a grid, pooling the processing sources of numerous popular machines.

C Interview Questions
Question 6. What Is Storage Virtualization?

Answer :

The Oracle Automatic Storage Management (ASM) is a characteristic of Oracle Database 10g which provides a digital layer among the database and garage in order that group of disks can be handled as a single disk institution and disks may be dynamically brought or removed at the same time as preserving databases online.

Question 7. What Is Grid Management Feature?

Answer :

The Grid Management function of Oracle Enterprise Manager 10g provides a unmarried console to control more than one systems collectively as a logical institution.

C Tutorial Oracle 11g Interview Questions
Question eight. When Oracle Allocates An Sga?

Answer :

When Oracle starts offevolved, it reads the initialization parameter document to determine the values of initialization parameters. After this, it allocates an SGA and creates historical past processes.

Question 9. What Is An Oracle Instance?

Answer :

When you begin, the database example comes into photograph into gadget memory. Combination of the SGA and the Oracle approaches is referred to as an Oracle example.

C & Data Structures Interview Questions
Question 10. What Are The Several Tools For Interacting With The Oracle Database Using Sql?

Answer :

There are numerous equipment for interfacing with the database the use of SQL:

Oracle SQL*Plus and iSQL*Plus 
Oracle Forms, Reports, and Discoverer
Oracle Enterprise Manager 
Third-celebration equipment
Oracle 11g Tutorial
Question eleven. How Oracle Works?

Answer :

An example has began at the database server.
A patron established a connection to the server, the use of the proper Oracle Net Services driver.
The server creates a committed server technique on behalf of the consumer system.
The person executes SQL announcement and commits the transaction.
The server process gets the announcement and assessments for any shared SQL region that incorporates a comparable SQL.
The server process retrieves records from datafile (table) or SGA.
The server process modifies records within the SGA vicinity. The DBWn procedure writes modified blocks permanently to disk. The LGWR method facts the transaction within the redo log record.
The server technique sends a message to the software.
Basic Programming Interview Questions
Question 12. What Contains Oracle Physical Database Structure?

Answer :

It includes

Datafiles
Control Files
Redo Log Files
Archive Log Files
Parameter Files
Alert and Trace Log Files
Backup Files
Oracle 9i Interview Questions
Question 13. What Is A Tablespace

Answer :

Oracle use Tablespace for logical statistics Storage. Physically, information will get saved in Datafiles. Datafiles could be connected to tablespace. A tablespace will have multiple datafiles. A tablespace may have items from exceptional schema's and a schema will have more than one tablespace's. Database creates "SYSTEM tablespace" by default during database advent. It consists of study only records dictionary tables which contains the statistics approximately the database. 

Question 14. What Is A Control File?

Answer :

Control document is a binary document which stores Database call, associated statistics files, redo files, DB creation time and current log sequence variety. Without manage record database can not be started and may impede facts recuperation.

Question 15. What Are Data Blocks?

Answer :

Oracle stores information in information blocks also referred to as as logical blocks, Oracle blocks or pages. A facts block represents precise wide variety of bytes of space on disk.

 

Oracle 7.Three Interview Questions
Question sixteen. What Is An Extent?

Answer :

An quantity is a selected range of consecutive statistics blocks allocated for storing a selected sort of statistics.

Question 17. What Is A Segment?

Answer :

A phase is a group of extents, every of which has been allotted for a selected records structure and all of that are saved in the identical table-space.

Pro*C/C++ Interview Questions
Question 18. What Is Rollback Segment ?

Answer :

Database include one or more Rollback Segments to roll back transactions and facts recuperation.

C Interview Questions
Question 19. What Are The Different Type Of Segments ?

Answer :

Data Segment(for storing User Data), Index Segment (for storing index), Rollback Segment and Temporary Segment.

Question 20. What Is An Oracle Schema?

Answer :

A person account and its associated records together with tables, perspectives, indexes, clusters, sequences,methods, features, triggers,programs and database hyperlinks is referred to as Oracle schema. System, SCOTT and so forth are default schema's. We can create a brand new Schema/User. But we can't drop default database schema's.

Microsoft Visual C++ Interview Questions
Question 21. When And How Oracle Database Creates A Schema?

Answer :

Oracle Database automatically creates a schema when you create a person.

Question 22. What Is A View?

Answer :

A view is a tailored presentation of the facts contained in one or greater tables or other views. A view is output of a question and treats it as a table. Therefore, a view may be notion of as a stored query or a digital table. A view isn't always assigned any garage space, nor does a view actually include statistics.

Question 23. How Views Are Used?

Answer :

It offers protection by using proscribing access to a predetermined set of rows or columns of a desk. It hides data complexity. It simplifies statements for the person.
An example would be the views, which allow customers to pick records from a couple of tables without really knowing a way to carry out a join.
It gives the information in a one of a kind attitude from that of the bottom table. It isolate applications from modifications in definitions of base tables. It saves complex queries.

Advanced C++ Interview Questions
Question 24. What Are Materialized Views?

Answer :

These are schema objects which can be used to summarize, compute, mirror, and distribute statistics. They can be utilized in numerous environments for computation such as statistics warehousing, choice help, and dispensed or mobile computing and it also gives neighborhood get right of entry to to records as opposed to accessing from far off sites. In statistics warehouses, MVs are used to compute and save aggregated statistics.

Oracle 11g Interview Questions
Question 25. What Is A Dimension?

Answer :

A size is hierarchical relationships among pairs of columns or column sets. Each fee at the child degree is tied with one price on the determine level. A dimension is a field of logical relationships among columns and it does not comprise any facts.

Question 26. Explain Sequence Generator In Oracle?

Answer :

The series generator gives a sequential series of numbers.The sequence generator is mainly beneficial for generating particular sequential numbers. Sequence numbers are Oracle integers of as much as 38 digits defined within the database. A sequence definition affords data, which include:

The sequence name
ascending or descending collection
The c language between numbers
Whether Oracle must cache collection numbers in reminiscence
Sequence numbers are generated impartial of any tables. The identical series generator may be used for many tables. Sequence wide variety technology may be used to produce number one keys to your data robotically. Oracle shops the definitions of all sequences for a particular database as rows in records dictionary table within the SYSTEM desk- area.

C and C++ Interview Questions
Question 27. What Is An Index?

Answer :

Indexes are structures associated with tables and clusters. You can create indexes on one or extra columns of a table to enhance the speed of SQL assertion execution on that desk. Just because the index in Oracle manual helps you to locate information quicker than if there have been no indexes. An Oracle index provides a faster get entry to direction to desk records.

C & Data Structures Interview Questions
Question 28. List Out Indexing Scheme That Oracle Provides?

Answer :

Oracle offers numerous indexing schemes:

B-tree indexes
B-tree cluster indexes
Hash cluster indexes
Reverse key indexes
Bitmap indexes
Bitmap join indexes
Question 29. What Is A Synonyms?

Answer :

A synonym is an alias for database gadgets including desk, view, materialized view, series, procedure, characteristic, bundle. Because a synonym is in reality an alias, it does not require storage aside from its facts dictionary definition.

Basic C Interview Questions
Question 30. Give An Example Of Synonyms?

Answer :

CREATE PUBLIC SYNONYM income FOR jward.Sales_data;
After the general public synonym is created, you could query the desk SALES_DATA with a easy SQL announcement:
SELECT * FROM income;

Question 31. What Is Concurrency In Oracle?

Answer :

The multiuser database management system's concern is how to manipulate concurrency, that is the concurrent access of the same facts by using a couple of users. Without sufficient concurrency controls, facts could be up to date or changed improperly, trading off with records integrity. To control information concurrency is to make every user anticipate a turn.
The purpose of a database control device is to lower the waiting time so it's miles either nonexistent or negligible to each person. The statistics manipulation language statements must continue with as little intervention as possible, and destructive interactions amongst concurrent transactions must be averted.
Destructive interplay is any interaction that updates facts or alters underlying information structures incorrectly. Neither performance nor facts integrity can be sacrificed. Oracle solves such troubles via using diverse sorts of locks and a multi-model consistency model.

Question 32. Explain Briefly Shared Server Architecture?

Answer :

This architecture gets rid of the need for a dedicated server system for every connection. A dispatcher routes various incoming community consultation requests to a shared server strategies pool. An idle shared server method from a shared pool of server tactics chooses a request from a not unusual queue, this means that a small range of shared servers can do the same amount of processing as many dedicated servers.
It is because of the amount of memory required for each person is relatively small, much less memory and technique management are required, and greater customers may be supported.

Question 33. What Are Archiver Processes?

Answer :

It copies redo log documents to a chosen storage tool after a log transfer has took place. Archiver tactics are there most effective whilst the database is in ARCHIVELOG mode, and automated archiving is enabled. An Oracle instance could have up to ten Archiver procedures (ARC0 to ARC9). The LGWR method begins a new ARCn technique every time the current quantity of Archiver techniques is inadequate to deal with the workload.

Basic Programming Interview Questions
Question 34. What Are Job Queue Processes?

Answer :

Job queue strategies are used for processing batch. They run user jobs. They may be viewed as a scheduler provider that may be used to time table jobs like PL/SQL statements or approaches on an Oracle example.

Question 35. What Is Recoverer Process?

Answer :

The re-coverer system (RECO) is a heritage system used with the distributed database configuration that mechanically resolves screw ups. The RECO method of a node robotically connects to different databases concerned in an in- doubt distributed transaction.

Question 36. What Is Process Monitor Process?

Answer :

It performs technique recuperation when a user system fails. Process Monitor is accountable for cleansing up the database buffer cache and reclaiming resources that the consumer technique changed into the use of. Process Monitor also registers records about the example and dispatcher techniques with the community listener.

Oracle 7.3 Interview Questions
Question 37. What Is System Monitor Process?

Answer :

It performs recuperation, if important, at example startup.
If any terminated transactions were skipped at some point of instance recuperation because of file-read or offline mistakes, System Monitor Process recovers them when the tablespace or report is added again online.
With Application Clusters, the System Monitor procedure of one instance can perform example recovery for a failed CPU or example.

Question 38. What Is Log Writer Process?

Answer :

It is liable for writing the redo log buffer to a redo log record on disk. Log Writer writes all redo entries that is copied into the buffer since the final time it wrote.
When a user troubles a commit announcement, Log Writer troubles a devote record inside the redo log buffer and writes it to disk without delay, along with the transaction’s redo entries. The corresponding changes to information blocks are delayed till it's far greater efficient to jot down them. This is referred to as a quick devote mechanism.

Question 39. What Is Database Writer Process?

Answer :

It writes the contents of buffers to records documents.The DBWn approaches are responsible for writing changed buffers inside the database buffer cache to disk.
However one database author technique (DBW0) is enough for most structures, you can configure different techniques (DBW1 via DBW9 and DBWa thru DBWj) to enhance write overall performance if your machine manipulates records very a lot. These extra DBWn tactics are not useful on uniprocessor systems.

Question forty. What Are The Processes Does Background Processes In An Oracle Includes?

Answer :

The heritage procedures in an Oracle example can include the subsequent:

Database Writer Process (DBWn)
Log Writer Process (LGWR)
Checkpoint Process (CKPT)
System Monitor Process (SMON)
Process Monitor Process (PMON)
Recoverer Process (RECO)
Job Queue Processes
Achiever Processes (ARCn)
Queue Monitor Processes (QMNn)
Pro*C/C++ Interview Questions
Question forty one. What Are Background Processes In Oracle?

Answer :

In order to decorate overall performance and accommodate many users, a multi-system Oracle device uses a few extra Oracle strategies called historical past techniques.

Question 42. What Server Processes Can Perform Created On Behalf Of Each User’s Application?

Answer :

Server approaches can carry out one or greater of the subsequent:

Parses and executes SQL statements fired thru the software.
Reads information blocks from datafiles on disk into the shared database buffers of the System Global Area, if the blocks are not already gift within the System Global Area.
Return effects in one of these way that the utility can manner the information.
Microsoft Visual C++ Interview Questions
Question 43. What Are Server Processes In Oracle?

Answer :

Oracle creates server techniques to serve user techniques requests, related to the example. In some conditions, while the utility and Oracle are at the equal system, it is feasible to mix the consumer system and corresponding server procedure into one manner for reducing machine overhead. However, when the software and Oracle operate on distinctive computers, a user system usually talks to Oracle through a separate server method.

Question forty four. What Are Dedicated And Shared Server Process?

Answer :

Server Configurations:

Dedicated server method
Shared server manner
The server method created on behalf of each person process is called a devoted server system (or shadow manner).Shared server architecture removes the need for a dedicated server method for every connection.
A dispatcher routes more than one incoming community consultation requests to a pool of shared server tactics. 
An idle shared server manner from a pool of shared server methods selections up a request from a common queue, which does suggest a small range of shared servers can do the same quantity of processing as many devoted servers.

Question 45. What Are The Contents Of Pga?

Answer :

Content of the Program Global Area : The content of the Program Global Area memory varies, depending on whether or not the instance is walking the shared server option. But in wellknown, the PGA reminiscence may be classified inside the following manner.
Private SQL Area : A private SQL region consists of facts together with bind statistics and runtime memory structures. 
Cursors and SQL Areas : Session reminiscence is the reminiscence assigned to hold a consultation's variables (logon information) and other consultation information. The session reminiscence is shared and not private for a shared server.
SQL Work Areas: For complicated queries including selection-support queries, a large portion of the runtime place is devoted to work regions allocated by means of reminiscence- intensive operators.
Question forty six. What Is Pga?

Answer :

A PGA i.E Program Global Area is a memory place that includes records and manage information for a server system.It is a reminiscence created by means of Oracle when a server technique is began and it's far non shared. Access to it's miles distinctive to that server process and is examine and written by using Oracle code.
The total PGA reminiscence allocated by every server manner related to an Oracle instance is also known as aggregated PGA memory allotted by using the example.

Question forty seven. What Is Shared Pool?

Answer :

The Shared Pool part of the System Global Area includes the library cache, the dictionary cache, buffers for parallel execution messages, and manipulate systems.

Question forty eight. What Is Redo Log Buffer?

Answer :

The Redo Log Buffer is a round buffer inside the System Global Area that holds records about changes made to the database. Redo entries incorporate the records to reconstruct, or redo, adjustments made to the database with the aid of INSERT, UPDATE, DELETE, CREATE, ALTER, or DROP operations. Redo entries are used for database recuperation, if essential.

Question 49. What Are Database Buffers?

Answer :

It is the portion of the System Global Area that holds copies of facts blocks examine from datafiles. All person procedures are connected to the example concurrently and proportion get admission to to the database buffer cache.

Question 50. What Are The Data Structures Does Sga Contains?

Answer :

The SGA incorporates the subsequent data systems:

Database buffer cache
Redo log buffer
Shared pool
Java pool
Large pool (elective)
Streams pool
Data dictionary cache
Other miscellaneous statistics
Question 51. What Is Difference Between C And C++?

Answer :

C++ is Multi-Paradigm ( now not natural OOP, supports both procedural and object oriented) at the same time as C follows procedural style programming.
In C records safety is much less, however in C++ you may use modifiers in your magnificence members to make it inaccessible from outdoor.
C follows top-down approach ( solution is created in step by step way, like every step is processed into info as we continue ) but C++ follows a bottom-up technique ( in which base elements are installed first and are connected to make complicated solutions ).
C++ helps function overloading at the same time as C does now not assist it.
C++ permits use of capabilities in structures, but C does now not permit that.
C++ helps reference variables (  variables can point to same reminiscence place ). C does no longer support this.
C does not have a built in exception coping with framework, though we can emulate it with other mechanism. C++ directly supports exception dealing with, which makes existence of developer clean.

Question fifty two. What Is A Class?

Answer :

Class defines a datatype, it is type definition of class of issue(s). But a category without a doubt does no longer outline the statistics, it simply specifies the structure of statistics. To use them you need to create gadgets out of the magnificence. Class may be taken into consideration as a blueprint of a constructing, you cannot live internal blueprint of building, you want to assemble constructing(s) out of that plan. You can create any variety of buildings from the blueprint, similarly you can create any quantity of objects from a class.
Magnificence Vehicle

    public:
        int numberOfTyres;
        double engineCapacity;
        void pressure()
            // code to pressure the automobile
        
;

Question 53. What Is An Object/instance?

Answer :

Object is the instance of a category, that's concrete. From the above example, we can create instance of class Vehicle as given underneath Vehicle vehicleObject;
We can have exceptional gadgets of the elegance Vehicle, as an example we can have Vehicle items with 2 tyres, 4tyres etc. Similarly special engine capacities as well.

Question 54. What Do You Mean By C++ Access Specifiers?

Answer :

Access specifiers are used to outline how the members (functions and variables) may be accessed outdoor the class. There are 3 get right of entry to specifiers described that are public, non-public, and guarded
non-public : Members declared as non-public are reachable only with in the equal magnificence and they can not be accessed outdoor the class they're declared.
Public : Members declared as public are accessible from any where.
Protected : Members declared as included can not be accessed from outside the class besides a child class. This get right of entry to specifier has importance inside the context of inheritance.

Question 55. What Are The Basics Concepts Of Oop?

Answer :

Encapsulation : Encapsulation is the mechanism by which facts and associated operations/techniques are certain together and thus hide the facts from out of doors international. It's also known as records hiding. In c++, encapsulation carried out using the get admission to specifiers (private, public and guarded). Data contributors may be declared as personal (hence shielding from direct get right of entry to from outdoor) and public techniques may be provided to get admission to those statistics. Consider the underneath magnificence
class Person

   non-public:
      int age;
   public:
      int getAge()
        return age;
      
      int setAge(int cost)
        if(fee > zero)
            age = price;
        
      
;

In the magnificence Person, get admission to to the records field age is protected by maintaining it as private and supplying public get entry to methods. What could have took place if there has been no get entry to techniques and the field age turned into public? Anybody who has a Person object can set an invalid price (poor or very huge cost) for the age area. So by way of encapsulation we can preventing direct access from outdoor, and as a consequence have whole manage, protection and integrity of the information.
Data abstraction : Data abstraction refers to hiding the inner implementations and display best the important details to the out of doors global. In C++ data abstraction is carried out the usage of interfaces and abstract lessons.
Class Stack

    public:
        virtual void push(int)=0; 
        digital int pop()=zero;
;
elegance MyStack : public Stack

    non-public:
        int arrayToHoldData[]; //Holds the facts from stack
    public:
        void push(int) 
            // implement push operation the usage of array
        
        int pop()
            // put in force pop operation using array
        
;
In the above example, the out of doors world only need to recognise approximately the Stack magnificence and its push, pop operations. Internally stack may be implemented the use of arrays or connected lists or queues or something that you could think of. This method, so long as the push and pa method plays the operations paintings as expected, you've got the liberty to alternate the internal implementation without affecting other applications that use your Stack elegance.
Inheritance : Inheritance allows one magnificence to inherit houses of any other magnificence. In other words, inheritance permits one magnificence to be defined in phrases of any other elegance.
Class SymmetricShape

    public:
        int getSize()
        
            return size;
        
        void setSize(int w)
        
            length = w;
        
    blanketed:
        int size;
;
// Derived class
class Square: public SymmetricShape

    public:
        int getArea()
         
            return (length * size); 
        
;

In the above example, class Square inherits the homes and techniques of sophistication SymmetricShape. Inheritance is the one of the very important standards in C++/OOP. It facilitates to modularise the code, improve reusability and decreases tight coupling among additives of the device.

Question 56. What Is The Use Of Volatile Keyword In C++? Give An Example ?

Answer :

Most of the times compilers will do optimization to the code to speed up the program. For instance in the underneath code,
int a = 10;
even as( a == 10)
     // Do something

compiler might imagine that value of 'a' isn't getting changed from the program and replace it with 'even as(actual)', in order to bring about an limitless loop. In actual state of affairs the fee of 'a' may be getting updated from outside of the program.
Volatile keyword is used to inform compiler that the variable declared the use of risky may be used from out of doors the current scope in order that compiler wont apply any optimization. This subjects handiest in case of multi-threaded programs.
In the above instance if variable 'a' became declared using risky, compiler will now not optimize it. In shot, cost of the risky variables can be read from the memory vicinity at once.

Question fifty seven. In How Many Ways We Can Initialize An Int Variable In C++?

Answer :

In c++, variables may be initialized in two approaches, the traditional C++ initialization using "=" operator and 2d using the constructor notation.
Traditional C++ initilization
int i = 10;
variable i will get initialized to ten.
Using C++ constructor notation
int i(10);

Question 58. What Is Implicit Conversion/coercion In C++?

Answer :

Implicit conversions are accomplished while a kind (say T) is used in a context where a well suited kind (Say F) is predicted so that the kind T can be promoted to kind F.
Brief a = 2000 + 20;
In the above instance, variable a will get mechanically promoted from quick to int. This is known as implicit conversion/coercion in c++.

Question 59. What Are C++ Inline Functions?

Answer :

C++ inline capabilities are unique features, for which the compiler replaces the function name with frame/definition of characteristic. Inline features makes this system execute faster than the ordinary capabilities, because the overhead concerned in saving contemporary nation to stack on the function call is prevented. By giving developer the manipulate of making a function as inline, he can similarly optimize the code based totally on application common sense. But actually, it is the compiler that makes a decision whether or not to make a characteristic inline or no longer no matter it is assertion. Compiler may additionally choose to make a non inline characteristic inline and vice versa. Declaring a characteristic as inline is in impact a request to the compiler to make it inline, which compiler might also ignore. So, please word this factor for the interview that, it's miles upto the compiler to make a function inline or not.
Inline int min(int a, int b)

   go back (a < b)? A : b;

int main( )

   cout << "min (20,10): " << min(20,10) << endl;
   cout << "min (0,2 hundred): " << min(0,200) << endl;
   cout << "min (one hundred,1010): " << min(100,1010) << endl;
   return zero;

If the complier makes a decision to make the feature min as inline, then the above code will internally look as if it became written like
int fundamental( )

   cout << "min (20,10): " << ((20 < 10)? 20 : 10) << endl;
   cout << "min (0,2 hundred): " << ((0 < two hundred)? 0 : 200) << endl;
   cout << "min (a hundred,1010): " << ((a hundred < 1010)? 100 : 1010) << endl; 
 return 0;


Question 60. What Do You Mean By Translation Unit In C++?

Answer :

We prepare our C++ packages into specific supply documents (.Cpp, .Cxx and so forth). When you don't forget a supply report, at the preprocessing stage, a few extra content material can also get brought to the supply code ( for example, the contents of header documents blanketed) and some content material may additionally get removed ( as an example, the a part of the code within the #ifdef of #ifndef block which clear up to fake/0 primarily based on the symbols described). This powerful content material is referred to as a translation unit. In other phrases, a translation unit includes Contents of supply report Plus contents of files protected immediately or  in a roundabout way Minus source code lines unnoticed by means of any conditional pre processing directives ( the strains ignored with the aid of #ifdef,#ifndef and so on)

Question 61. What Do You Mean By Internal Linking And External Linking In C++?

Answer :

A image is said to be connected internally when it is able to be accessed most effective from with-within the scope of a unmarried translation unit. By outside linking a image may be accessed from different translation units as well. This linkage can be controlled with the aid of the use of static and extern key phrases.

Question 62. What Do You Mean By Storage Classes?

Answer :

Storage magnificence are used to specify the visibility/scope and life time of symbols(functions and variables). That method, storage classes specify in which all a variable or feature may be accessed and until what time those variables may be to be had throughout the execution of software.

Question 63. What Are The Difference Between Reference Variables And Pointers In C++?

Answer :

Pointers:

Pointers can be assigned to NULL
Pointers may be (re)pointed to any object, at any time, any wide variety of times in the course of the execution.
Pointer has personal memory address and region on stack
Reference Variables:

References cannot be assigned NULL. It must constantly be associated with real memory, now not NULL.
Reference variables must be initialized with an item while they're created and they can not be reinitialized to refer to every other item
Reference variables has vicinity on stack, however shares the equal reminiscence vicinity with the item it discuss with.
Question sixty four. What Is Meant By Reference Variable In C++?

Answer :

In C++, reference variable lets in you create an alias (second name) for an already existing variable. A reference variable can be used to access (read/write) the original information. That way, both the variable and reference variable are attached to equal memory area. In impact, if you change the cost of a variable the use of reference variable, both will get modified (because both are connected to same reminiscence place).

Question 65. How To Create A Reference Variable In C++?

Answer :

Appending an ampersand (&) to the stop of datatype makes a variable eligible to apply as reference variable.
Int a = 20;
int& b = a;
The first announcement initializes a an integer variable a. Second announcement creates an integer reference initialized to variable a Take a study the below example to see how reference variables paintings.
Int foremost ()

int   a;
int&  b = a;
a = 10;
cout << "Value of a : " << a << endl;
cout << "Value of a reference (b) : " << b  << endl;
b = 20;
cout << "Value of a : " << a << endl;
cout << "Value of a reference (b) : " << b  << endl;
return zero;

Above code creates following output.
Value of a : 10
Value of a reference (b) : 10
Value of a : 20
Value of a reference (b) : 20

Question 66. What You Mean By Early Binding And Late Binding? How It Is Related To Dynamic Binding?

Answer :

Binding is the method of linking real address of functions or identifiers to their reference. This occurs mainly two instances.
During compilation : This is known as early binding
 For all the direct characteristic references compiler will update the reference with real deal with of the approach.
At runtime : This is known as late binding.
In case of digital feature calls the use of a Base reference, compiler does not understand which method will get referred to as at run time. In this situation compiler will update the reference with code to get the deal with of feature at runtime.
Dynamic binding is some other call for overdue binding.

Question 67. What Is Virtual Destructor? Why They Are Used?

Answer :

Virtual destructors are used for the equal reason as digital features. When you remove an object of subclass, that is referenced through a figure elegance pointer, most effective destructor of base elegance gets performed. But if the destructor is described the usage of virtual key-word, both the destructors [ of parent and sub class ] gets invoked.

Question 68. Why Pure Virtual Functions Are Used If They Don't Have Implementation / When Does A Pure Virtual Function Become Useful?

Answer :

Pure virtual features are used when it would not make sense to provide definition of a digital feature within the base magnificence or a right definition does now not exists within the context of base magnificence. Consider the above example, class SymmetricShape is used as base magnificence for shapes with symmetric shape(Circle, rectangular, equilateral triangle and so on). In this situation, there exists no right definition for characteristic draw() inside the base elegance SymmetricShape instead the child instructions of SymmetricShape (Cirlce, Square etc) can implement this method and draw proper form.

Question 69. How To Create A Pure Virtual Function?

Answer :

A characteristic is made as pure digital function through the the use of a selected signature, " = 0" appended to the feature assertion as given underneath,
class SymmetricShape 
    public:
        // draw() is a natural virtual characteristic.
        Digital void draw() = zero;
;

Question 70. What Do You Mean By Pure Virtual Functions In C++? Give An Example?

Answer :

Pure digital feature is a characteristic which does not have an implementation and the same wishes to be carried out by way of the the next immediate non-abstract elegance. (A magnificence turns into an summary magnificence if there may be at-least a single pure virtual characteristic and for this reason natural digital features are used to create interfaces in c++).

Question seventy one. What Are Virtual Functions And What Is Its Use?

Answer :

Virtual functions are member capabilities of class which is asserted the usage of keyword 'digital'. When a base class type reference is initialized using object of sub elegance type and an overridden approach which is declared as digital is invoked the usage of the bottom reference, the technique in baby elegance item gets invoked.
Magnificence Base

    int a; 
    public:
        Base()
        
            a = 1;
        
        digital void technique()
        
            cout << a;
        
;
elegance Child: public Base

    int b;
    public: 
        Child()
        
            b = 2; 
        
        virtual void method()
         
            cout << b;
        

int main()

    Base *pBase; 
    Child oChild;
    pBase = &oChild;
    pBase->method(); 
    go back zero;

In the above example despite the fact that the method in invoked on Base magnificence reference, technique of the child gets invoked considering the fact that its declared as virtual.

Question 72. How Many Storage Classes Are Available In C++?

Answer :

Storage magnificence are used to specify the visibility/scope and lifestyles time of symbols(functions and variables). That way, storage training specify wherein all a variable or characteristic can be accessed and until what time the ones variables will be available all through the execution of application.
Following storage classes are to be had in C++
auto : It's the default storage magnificence for local variables. They may be accessed most effective from with inside the declaration scope. Auto variables are allotted at the beginning of enclosing block and deallocated on the end of enclosing block.
Register : It's just like automobile variables. Difference is that sign in variables might be saved on the processor check in as opposed to RAM, meaning the most length of sign up variable have to be the dimensions of CPU sign up ( like 16bit, 32bit or 64bit). This is normally used for often accessed variables like counters, to enhance performance. But observe that, asserting a variable as sign in does no longer suggest that they may be saved within the sign in. It relies upon on the hardware and implementation.
Static : A static variable might be saved in life till the quit of the program in contrast to growing and destroying each time they pass into and out of the scope. This helps to maintain their fee even supposing manipulate is going out of the scope. When static is used with global variables, they may have internal linkage, which means it can't be accessed by means of other supply documents. When static is used in case of a category member, it will be shared by means of all of the objects of a category as opposed to developing separate copies for each object.
Extern :extern is used to tell compiler that the symbol is described in any other translation unit (or in a manner, source documents) and no longer in the modern one. Which manner the symbol is linked externally. Extern symbols have static garage period, this is handy through out the existence of program. Since no storage is allotted for extern variable as part of assertion, they cannot be initialized at the same time as declaring.
Mutable : mutable storage class can be used handiest on non static non const information a member of a category. Mutable information member of a class may be changed even is it is part of an object which is said as const.

Question seventy three. What Is 'copy Constructor' And When It Is Called?

Answer :

Copy constructor is a special constructor of a category that is used to create replica of an item. Compiler will give a default replica constructor if you don't define one. This implicit constructor will copy all the participants of supply item to goal object.
Implicit copy constructors are not encouraged, due to the fact if the supply item incorporates hints they will be copied to goal item, and it is able to purpose heap corruption while each the objects with guidelines referring to the same location does an replace to the reminiscence area. In this example its higher to outline a custom reproduction constructor and do a deep replica of the object.
        Elegance SampleClass
            public:
                int* ptr;
                SampleClass();
                // Copy constructor announcement
                SampleClass(SampleClass &obj);
        ;
        SampleClass::SampleClass()
            ptr = new int();
            *ptr = 5;
        
        // Copy constructor definition
        SampleClass::SampleClass(SampleClass &obj)
            //create a new object for the pointer
            ptr = new int();
            // Now manually assign the fee
            *ptr = *(obj.Ptr);
            cout<<"Copy constructor...N";
        

Question seventy four. What Is Realloc() And Free()? What Is Difference Between Them?

Answer :

void* realloc (void* ptr, size_t length) : This function is used to trade the dimensions of reminiscence item pointed by address ptr to the size given by means of length. If ptr is a null pointer, then realloc will behave like malloc(). If the ptr is an invalid pointer, then described behaviour might also occur depending the implementation. Undefined behaviour may additionally occur if the ptr has formerly been deallocated by means of unfastened(), or dealloc() or ptr do not suit a pointer lower back by means of an malloc(), calloc() or realloc().
Void unfastened (void* ptr) : This function is used to deallocate a block of memory that become allocated the use of malloc(), calloc() or realloc(). If ptr is null, this characteristic does not doe something.

Question 75. What Is Difference Between Shallow Copy And Deep Copy? Which Is Default?

Answer :

When you do a shallow replica, all the fields of the supply item is copied to target object as it's miles. That means, if there may be a dynamically created area within the source item, shallow copy will copy the identical pointer to target object. So you may have two objects with fields which are pointing to same memory place which isn't always what you generally need.
In case of deep copy, rather than copying the pointer, the object itself is copied to target. In this case if you alter the goal item, it's going to no longer have an effect on the source. By default reproduction constructors and project operators do shallow replica. To make it as deep copy, you need to create a custom replica constructor and override task operator.

Question 76. What Do You Mean By Persistent And Non Persistent Objects?

Answer :

Persistent objects are the ones which we may be serialized and written to disk, or any other stream. So earlier than stopping your application, you may serialize the item and on restart you could deserialize it. [ Drawing applications usually use serializations.]
Objects that cannot be serialized are called non chronic gadgets. [ Usually database objects are not serialized because connection and session will not be existing when you restart the application. ]

Question 77. Is It Possible To Get The Source Code Back From Binary File?

Answer :

Technically it is feasible to generate the supply code from binary. It is referred to as reverse engineering. There are lot of reverse engineering equipment available. But, in real case maximum of them will no longer re generate the exact supply code back due to the fact many facts might be misplaced because of compiler optimization and different interpretations.

Question 78. What Is The Difference Between #consist of And #include "file" ?

Answer :

We use # encompass to include a document. The difference between two methods of record inclusion lies within the order in which preprocessor searches for the file designated. When the preprocessor encounters #encompass announcement, it appears for the document particular in the angled brackets within the default region (Path defined in INCLUDE surroundings variable of the system).
When # encompass followed by using record call in double citation marks is encountered through the preprocessor, it appears for the document inside the modern-day directory. If the document is not found in the contemporary listing, it'll look for the record inside the default area.

Question 79. Can #consist of Handle Other File Formats Than .H?

Answer :

Yes. Irrespective of the report type, Preprocessor will do its job and will encompass any file like take a look at.Z.

Question 80. What Is A Void Pointer?

Answer :

A void pointer is a unique pointer kind that could factor to any data kind without letting the compiler recognize. It facilitates to bypass a pointer to a few function of any kind which may be decided at run time. In the following example input parameter a and b may be each integer and string.
Void PointerVoid(int type, void *a, void *b, void *c)

   if(kind == 1)/* int*/
   *c = ((int) *a) + ((int)*b);
   else /*string*/
   sprintf((char*)c,”%spercents”,(char*)a,(char*b));


Question eighty one. What Is The Value Of Null?

Answer :

The fee of NULL is zero or (void*)zero. Whenever NULL has to be in comparison with some variable or assigned to a variable, relying upon the form of that variable, the value of NULL might be decided.

Question eighty two. Can The Size Of An Array Be Declared At Runtime?

Answer :

No. The size of an array ought to be stated at the time of compilation. Alternate way is to use dynamic allocation via calloc or malloc.

Question 83. What Is The Difference Between Malloc() And Calloc()?

Answer :

Calloc:

Allocates a area of memory huge sufficient to hold "n” factors of "length" bytes every.
Calloc initializes the entire memory with zero
Malloc:

Allocates "length" bytes of memory.
Malloc does not change the prevailing memory. So it returns a memory bite with garbage fee. 
Question eighty four. What Is The Heap In Memory?

Answer :

The heap is wherein malloc(), calloc(), and realloc() get reminiscence. The allocation of reminiscence from the heap is a lot slower than the stack. But, the heap is tons extra flexible about reminiscence allocation than the stack. Memory can be allocated and deallocated in any time and order. This heap memory isn't deallocated by way of itself, method free() has to be referred to as in an effort to accomplish that.

Question 85. What Will Be The Output Of The Following Code Snippet?

Answer :

glide num1 = 6 / four;
waft num2 = 6 / 4.0;
printf("6/4 == %f or %fn", num1, num2);
Output will be : 6/four == 1.000000 or 1. 500000. This is a case of operator promoting. The variable num1 is ready to “6/4”. Because, both three and 4 are integers. So integer division is performed on them and the result is the integer 0. The variable num2 is ready to “6/4.Zero”. Because four.0 is a glide, the variety 6 is transformed to a waft as properly, and the result might be floating price 1.Five.

Question 86. What Happens If You Free A Pointer Twice?

Answer :

It is surely dangerous to loose the same reminiscence two times. If the reminiscence has now not been reallocated in between, it's going to generate a “double unfastened” mistakes, because the reminiscence area has already been freed.

Question 87. How Does Free() Method Know About How Much Memory To Release?

Answer :

There's no concrete manner. Most structures, continues a tune of every memory block as related lists. When reminiscence is allotted, all of the blocks which might be given to that specific name are positioned right into a linked listing and the dimensions, block number and serial wide variety are written within the head node. There isn't any guarantee, although. But in some way or different, the system maintains track of each block to realize the scale of each allotted portion of the heap.

Question 88. How To Restrict A Header File From Including More Than Once?

Answer :

In C, to keep away from double inclusion, we use a encompass shield additionally referred to as macro guard. It is #ifndef - #endif pair. "ifndef" is a sign of “if now not described”.
#ifndef FAMILY_H
#outline FAMILY_H
struct Example

  int member;
;
#endif /* FAMILY _H */

Question 89. How To Print An Address?

Answer :

The nice way is to use "%p" in printf() or fprintf. The “%p” will inform compiler to apply the exceptional kind to apply, at the same time as printing the cope with in keeping with the surroundings, for the reason that length of a pointer changes from gadget to machine.

Question 90. Explain Recursive Functions? Also Explain The Advantages And Disadvantages Of Recursive Algorithms?

Answer :

A recursive function is a characteristic which calls itself.
The advantages of recursive functions are:

A replacement for terribly complex new release. For example, a recursive characteristic is fine to reduce the code length for Tower of Hanoi software.
Unnecessary calling of functions may be avoided.
The hazards of Recursive capabilities:

The exit point have to be explicitly coded ,in any other case stack overflow can also appear
A recursive function is regularly perplexing. It is difficult to hint the good judgment of the function. Hence, it's miles hard to debug a recursive characteristic.
Question ninety one. What Are The Standard Predefined Macros?

Answer :

ANSI C has six predefined macro. They are

__FILE__ - Name of the contemporary record
__LINE__ - Current line range
__TIME__ - Current time of compilation
__DATE__ - Current date of compilation
__cplusplus - If application compiled in C++ compiler
__STDC__ - If ANSI C is followed through the compiler strictly.
Question 92. What Is A Pragma?

Answer :

The #pragma preprocessor permits compiler to include or exclude compiler p




CFG