Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8432725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:12:21+00:00 2026-06-10T06:12:21+00:00

I was asked these questions in a interview. Why exactly Binary code and Data

  • 0

I was asked these questions in a interview.

  1. Why exactly Binary code and Data was separated i.e why did they plan for Data segment why not everything inside code segment?

2.

class A
{
private :
    int i;
public:
    void show()
    {
        printf("hello");
    }
};
int main()
{
    A* a = NULL; (what happens in object table?)
        A* aa =  new A();  (what happens in object table?)

        a->show();
    aa->show();

    delete aa;
    return 0;
}

How exactly aa and a are different and how exactly object behaves inside memory.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:12:23+00:00Added an answer on June 10, 2026 at 6:12 am

    code segment vs data segment

    code segment is read-only, while data segment is read/write, if you mix these 2 sections together, update the data while keep the code secure becomes a challenge: one example is as Lol4t0 pointed out:

    As to the OS memory management, the code segment will be swap out to
    its original executable file on the file system, while the data
    segment, which is deemed to change, are swapped out to paging file. if you mixed them
    together, you may lose the advantage of reusing the executable as paging file.

    and also, code segment are usually load into memory pages which are readonly (VirtualAlloc(PAGE_READONLY))

    a(null) vs aa (non-null)

    a and aa themselves are simply stack variable of type A*, but a points to NULL, while aa points to an object allocated in heap.

    a->show() is translated into:

    A_show(a)
    //which is:
    A_show(NULL)
    

    because no member variable is referenced in show(), this should works fine.

    aa->show() is translated into:

    A_show(aa)
    

    here aa is a valid address, so even if you reference member variable in show(), it would work.

    Notice unlike virtual functions, which is resolved in runtime thus require a vptr in each object, member functions are just normal functions which take the this as first parameter, and resolved by compiler in compile time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These questions were asked me in a technical interview: If we deploy an application
I was recently in an interview where they asked me technical questions. One was
I attended interview for samsung. They asked lot of questions on memory layout of
Almost on every interview I'm asked some questions implies data structure implementation. Is there
One of the interview questions which they asked me very recently. What is an
I just had a quick phone interview. The interviewer asked me a few questions
I was asked this question in an interview - not sure if it makes
I was asked 2,3 questions in an interview which didn't make any sense. Difference
I guess this is one of the most commonly asked interview questions, yet I
Recently in an interview I was asked several questions related to the Big-O of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.