常见英文面试笔试题目

合集下载

职场面试英语试题及答案

职场面试英语试题及答案

职场面试英语试题及答案一、选择题1. What is the best way to greet someone in a job interview?A. Hi, how are you?B. Hello, nice to meet you.C. Hey, what's up?D. Good morning, I'm here for the interview.答案:D2. Which of the following is NOT a common question asked in a job interview?A. Why do you want to work for this company?B. Can you tell me about yourself?C. What is your favorite color?D. How do you handle stress?答案:C3. What should you do if you don't understand a question during an interview?A. Pretend you understood and give an answer.B. Ask the interviewer to repeat the question.C. Say nothing and hope they move on.D. Ask the interviewer to clarify the question.答案:D二、填空题4. When you are asked about your weaknesses, it's a good idea to mention a ________ that you are actively working onimproving.答案:strength5. It's important to research the company before theinterview to show that you are ________ about the position.答案:interested三、简答题6. Describe a situation where you had to work under pressure and how you handled it.答案:In a previous project, I was given a tight deadline to complete a report. I prioritized tasks, set milestones, and communicated regularly with my team to ensure we stayed on track. We managed to meet the deadline and deliver a high-quality report.7. Why do you think you would be a good fit for this position? 答案:I believe I would be a good fit for this position because my skills and experience align with the job requirements. I have a proven track record of success insimilar roles, and I am passionate about the industry.四、情景模拟题8. You are asked to give a brief self-introduction in a job interview. What would you say?答案:I would introduce myself by stating my name,educational background, and professional experience. I would highlight my key skills and achievements that are relevant to the position and express my enthusiasm for the opportunity to contribute to the company.9. How would you respond if the interviewer asks you about your salary expectations?答案:I would express that my primary goal is to find a role where I can contribute and grow professionally. While I am open to discussing compensation, I believe it's important to first understand the responsibilities and expectations of the role before discussing salary specifics.五、阅读理解题10. Read the following passage and answer the question below:"In today's competitive job market, it's crucial to stand out from the crowd. One way to do this is by showcasing your unique skills and experiences during a job interview. Employers are not only looking for candidates with the right qualifications but also those who can demonstrate their passion and fit for the company culture."Question: What does the passage suggest is important in a job interview?答案:The passage suggests that it's important to showcase unique skills and experiences, demonstrate passion, and fit the company culture during a job interview.。

52个英文面试问题及答案_面试技巧

52个英文面试问题及答案_面试技巧

52个英文面试问题及答案1、”what are your goals for the future?” or “where do you see yourself in five years?”don’t discuss your goals for returning to school or having a family, they are not relevant and could knock you out of contention for the job. rather, you want to connect your answer to the job you are applying for.最佳答案:-my long-term goals involve growing with a company where i can continue to learn, take on additional responsibilities, and contribute as much of value as i can.-i see myself as a top performing employee in a well-established organization, like this one. i plan on enhancing my skills and continuing my involvement in (related) professional associations.-once i gain additional experience, i would like to move on from a technical position to management.-in the xyz corporation, what is a typical career path for someone with my skills and experiences?2、tell me about yourself/ how would you describe yourself?you walk into the interview room, shake hands with your interviewer and sit down with your best interviewing smile on. guess what their first question is? “tell me about yourself.” your interviewer is not looking for a 10-minute dissertation here. instead, offer a razor sharp sentence or two that sets the stage for further discussion and sets you apart from your competitors.your unique selling proposition (usp)说出你的卖点give them “your synopsis about you” answer, specificallyyour unique selling proposition. known as a personal branding or a value-added statement, the usp is a succinct, one-sentence description of who you are, your biggest strength and the major benefit that a company will derive from this strength. here is an example of a unique selling proposition: “i’m a seasoned retail manager strong in developing training programs and loss prevention techniques that have resulted in revenue savings of over $2.3million for (employer’s name) during the past 11 years.”what a difference you’ve made with this statement. your interviewer is now sitting forward in her chair giving you her full attention. at this point, you might add the following sentence: “i’d like to discuss how i might be able to do something like that for you.” the ball is now back in her court and you have the beginnings of a real discussion and not an interrogation process.“my background to date has been centered around preparing myself to become the very best financial consultant i can become. let me tell you specifically how i’ve prepared myself. i am an undergraduate student in finance and accounting at _________ university. my past experiences has been in retail and higher education. both aspects have prepared me well for this career.”首先要明确他们想了解的是哪方面的内容do they want to know about your career so far, about your hobbies or family life? if in doubt, ask them to clarify what they wish you to talk about. then give a short factual answer, ending with “is there anything else you’d like to know about me?”how would you describe yourself?这个问题的答案应该是和他们的招聘广告上对于雇员的要求的基本一致,所以,看看你有哪些特质满足了他们的要求吧。

50个英文面试题及答案

50个英文面试题及答案

英文面试题1. Why do you want to work for our company?为什么你想要加入我们公司?Answer: I am impressed with your company's reputation for innovation, customer service, and commitment to sustainability. I believe that this is a company where I can make a meaningful contribution and grow my career.答案:我对贵公司的创新、客户服务和可持续发展承诺印象深刻。

我相信这是一家我可以做出有意义贡献并发展自己职业生涯的公司。

2. What experience do you have related to this job?你与这份工作有何相关经验?Answer: In my previous job, I was responsible for managing social media accounts and creating content for promotions and campaigns. I also conducted market research and analyzed data to measure the success of these campaigns. This experience has prepared me to take on similarresponsibilities in this role.答案:我之前的工作职责包括管理社交媒体账号并创作促销和营销活动的内容。

我也负责市场调研和分析数据来衡量这些活动的成功程度。

这些经验准备了我可以承担类似的职责。

3. How do you handle a difficult situation or challenge at work?你如何处理工作中的困难情况或挑战?Answer: I believe in approaching difficult situations with a calm and positive attitude. I try to remain objective and consider different perspectives before making a decision. I also make sure to communicate effectively with my team members and manager to address any challenges and find solutions.答案:我相信以冷静和积极的态度去面对困难的情况。

外贸英语面试笔试题及答案大全

外贸英语面试笔试题及答案大全

外贸英语面试笔试题及答案大全一、选择题1. What does "FOB" stand for in international trade?A. Free On BoardB. Free of BoardC. Full of BoardD. For the Board答案:A2. Which of the following is not a payment term in international trade?A. CIFB. DDPC. EXWD. FAS答案:B3. What is the meaning of "L/C" in international trade?A. Letter of CreditB. Letter of CreditorC. Letter of CustomerD. Letter of Contract答案:A二、填空题4. The term "CIF" includes the cost of goods, insurance, and ________.答案:freight5. When a company provides a ________, it is offering to pay for the goods upon delivery.答案:L/C (Letter of Credit)6. The term "EXW" means that the seller makes the goods available to the buyer at the seller's premises, and the buyer bears all the costs and risks from that point forward.答案:[无填空,直接陈述]三、简答题7. Explain the difference between a "Proforma Invoice" and a "Commercial Invoice".答案:A Proforma Invoice is a preliminary invoice provided by the seller to the buyer before the shipment of goods. It includes details of the transaction but is not a legal document for customs. A Commercial Invoice is a legal document required for customs clearance, which includes a detailed description of the goods, their value, and other necessary information for international trade.8. What are the key components of a Letter of Credit?答案:The key components of a Letter of Credit include theissuing bank, the advising bank, the beneficiary (seller), the applicant (buyer), the amount, the expiry date, the terms and conditions, and the required documents for presentation.四、案例分析题9. Assume you are a buyer and you have received a shipment of goods under a CIF contract. Upon inspection, you find that the goods are damaged. What steps should you take?答案:As a buyer under a CIF contract, you should first notify the seller and the shipping company of the damage. Then, you should file a claim with the insurance company, as CIF includes insurance. It is important to provide evidence of the damage, such as photographs and a surveyor's report. You may also need to involve the issuing bank if the payment was made through a Letter of Credit.五、论述题10. Discuss the importance of understanding different trade terms in international trade and how they can affect a company's risk and profit margins.答案:Understanding different trade terms is crucial in international trade as they define the responsibilities of each party involved in the transaction. They affect the risk and profit margins by determining who bears the costs and risks associated with the shipment of goods. For instance, under an EXW contract, the buyer bears all the costs andrisks from the seller's premises, which can be risky but may allow for better control over shipping costs. On the other hand, a DDP contract transfers all risks and costs to theseller until the goods are delivered to the buyer's premises, reducing the buyer's risk but potentially increasing the seller's costs and affecting profit margins.。

英语笔试及面试题目答案汇总(小编整理)

英语笔试及面试题目答案汇总(小编整理)

英语笔试及面试题目答案汇总(小编整理)第一篇:英语笔试及面试题目答案汇总1、So, tell me a little about yourself.You don’t need to explain everything from birth to present day.Relevant facts about education, your career and your current life situation are fine.2、Why are you looking(or why did you leave you last job)?This should be a straightforward question to answer, but it can trip you up.Presumably you are looking for a new job(or any job)because you want to advance your career and get a position that allows you to grow as a person and an employee.It’s not a good idea to mention money here, it can make you sound mercenary.And if you are in the unfortunate situation of having been downsized, stay positive and be a***rief as pos***le about it.If you were fired, you’ll need a good explanation.But once again, stay positive.3、Tell me what you know about this company.Do your homework before you go to any interview.Whether it’***eing the VP of marketing or the mailroom clerk, you should know about the company or business you’re going to work for.Has this company been in the news lately? Who are the people in the company you should know about? Do the background work, it will make you stand out as someone who comes prepared, and is genuinely interested in the company and the job.4.Why do you want to work at X Company?This should be directly related to the last question.Any research you’ve done on the company should have led you to the conclusion that you’d want to work there.After all, you’re at the interview, right? Put some thought into this answer before you have your interview, mention your career goals and highlight forward-thinking goals and career plans.5.What relevantexperience do you have? Hopefully if you’re applying fo r this position you have bags of related experience, and if that’s the case you should mention it all.But if you’re switching careers or trying something a little different, your experience may initially not look like it’s matching up.That’s when you need a little honest creativity to match the experiences required with the ones you have.People skills are people skills after all, you just need to show how customer service skills can apply to internal management positions, and so on.6.If your previous co-workers were here, what would they say about you? Ok, this is not the time for full disclosure.If some people from your past are going to say you’re a boring A-hole, you don’t need to bring that up.Stay positive, always, and maybe have a few specific quotes in mind.“They’d say I was a hard worker” or even better “John Doe has always said I was the most reliable, creative problem-solver he’d ever met.”7.Have you done anything to further your experience?This could include anything from night classes to hobbies and sports.If it’s related, it’s worth mentioning.Obviously anything to do with further education is great, but maybe you’re spending time on a home improvement project to work on skills such as self-sufficiency, time management and motivation.8.Where else have you applied?This is a good way to hint that you’re in demand, without sounding like you’re whoring yourself all over town.So, be honest and mention a few other companie***ut don’t go into detail.The fact that you’re seriously looking and keeping yo ur options open is what the interviewer is driving at.9.How are you when you’re working under pressure?Once again, there are a few ways to answer thi***ut theyshould all be positive.You may work well under pressure, you may thrive under pressure, and you may actually PREFER working under pressure.If you say you crumble like aged blue cheese, this is not going to help you get your foot in the door.10.What motivates you to do a good job?The answer to this one is not money, even if it is.You should be motiv ated by life’s noble pursuits.You want recognition for a job well done.You want to become better at your job.You want to help others or be a leader in your field.11.What’s your greatest strength?This is your chance to shine.You’re being asked to explain w hy you are a great employee, so don’t hold back and stay do stay positive.You could be someone who thrives under pressure, a great motivator, an amazing problem solver or someone with extraordinary attention to detail.If your greatest strength, however, is to drink anyone under the table or get a top score on Mario Kart, keep it to yourself.The interviewer is looking for work-related strengths.12.What’s your biggest weakness?If you’re completely honest, you may be kicking yourself in the butt.If you say yo u don’t have one, you’re obviously lying.This is a horrible question and one that politicians have become masters at answering.They say things like “I’m perhaps too committed to my work and don’t spend enough time with my family.” Oh, there’s a fireable offense.I’ve even heard “I think I’m too good at my job, it can often make people jealous.” Please, let’s keep our feet on the ground.If you’re asked this question, give a small, work-related flaw that you’re working hard to improve.Example: “I’ve been told I occasionally focus on details and miss the bigger picture, so I’ve been spending time laying out the complete project every day tosee my overall progress.”13.Let’s talk about salary.What are you looking for?Run for cover!This is one tricky game to play in an interview.Even if you know the salary range for the job, if you answer first you’re already showing all your cards.You want as much as pos***le, the employer wants you for as little as you’re willing to take.Before you apply, take a look at for a good idea of what someone with your specific experience should be paid.You may want to say, “well, that’s something I’ve thought long and hard about and I think someone with my experience should get between X & Y.” Or, you could be sly and say, “right now, I’m more interested in talking more about what the position can offer my career.” That could at least buy you a little time to scope out the situation.But if you do have a specific figure in mind and you are confident that you can get it, I’d sa y go for it.I have on many occasions, and every time I got very close to that figure(both below and sometimes above).14.Are you good at working in a team?Unless you have the I.Q.of a houseplant, you’ll always answer YES to this one.It’s the only answer.Ho w can anyone function inside an organization if they are a loner? You may want to mention what part you like to play in a team though;it’s a great chance to explain that you’re a natural leader.15.Tell me a suggestion you have made that was implemented.It’s important here to focus on the word “implemented.” There’s nothing wrong with having a thousand great ideas, but if the only place they live is on your notepad what’s the point? Better still, you need a good ending.If your previous company took your advice and ended up going bankrupt, that’s not such a great example either.Be prepared with a story about an idea of yours that wastaken from idea to implementation, and considered successful.16.Has anything ever irritated you about people you’ve worked with? Of course, you have a list as long as your arm.But you can’t say that, it shows you a***eing negative and difficult to work with.The best way to answer this one is to think for a while and then say something like “I’ve always got on just fine with my co-w orkers actually.”Use this question as a chance to show that you are a team player: “The only people I have trouble with are those who aren’t team players, who just don’t perform, who complain constantly, and who fail to respond to any efforts to motivate t hem.” The interviewer is expecting a response focused on personality and personal dislikes.Surprise her by delivering an answer that reflects company values 17.Is there anyone you just could not work with?No.Well, unless you’re talking about murderers, ra cists, rapists, thieves or other dastardly characters, you can work with anyone.Otherwise you could be flagged as someone who’s picky and difficult if you say, “I can’t work with anyone who’s a Bronco’s fan.Sorry.” 18.Tell me about any issues you’ve had with a previou process.Arrgh!If you fall for this one you shouldn’t be hired anyway.The interviewer is testing you to see if you’ll speak badly about your previous supervisor.Simply answer this question with exteme tact, diplomacy and if necessary, a big fat loss of memory.In short, you’ve never had any issues.The answer to 18 is completely wrong.I am a director at a major media company’s interactive division.Our company is expanding and I am almost in a constant state of hiring.I ask a variation of this question in every single interview and if a candidate has never had one issue or disagreement with anyone,(I stated a variation: I ask if it has happened with anyonein the workplace)I peg them as a liar and reject them immediately.I went well with my previou***oss.If there is an conflict, I will be open mind and talk about facts.once decision is made, I execute it well.19.Would you rather work for money or job satisfaction?It’s not a very fair question is it? We’d all love to get paid a Trump-like salary doing a job we love but that’s rare indeed.It’s fine to say money is important, but remember that NOTHING is more important to you than the job.Otherwise, you’re just someone looking for a bigger paycheck.20.Would you rather be liked or feared?I have been asked this a lot, in various incarnations.The first time I just drew a blank and said, “I don’t know.” That went over badly, but it was right at the start of my career when I had little to no experience.Since then I’ve realized that my genuine answer is “Neither, I’d rather be respected.” You don’t want to be feared because fear is no way to motivate a team.You may got the job done but at what cost? Similarly, if you’re everyone’***est friend you’ll find it difficult to make tough decisions or hit deadline s.But when you’re respected, you don’t have to be a complete bastard or a lame duck to get the job done.21.Are you willing to put the interests of X Company ahead of your own? Again, another nasty question.If you say yes, you’re a corporate whore who doesn’t care about family.If you say no, you’re disloyal to the company.I’m afraid that you’ll probably have to say yes to this one though, because you’re trying to be the perfect employee at this point, and perfect employees don’t cut out early for Jimmy’***a***all game.it is situational.if you…;if you ….Ethics and professionalism22.So, explain why I should hire you.As I’m sure you know,“because I’m great” or “I really need a job” are not good answers here.This is a time to give the employer a laundry list of your greatest talents that just so happen to match the job description.It’s also good to avoid taking potshots at other potential candidates here.Focus on yourself and your talents, not other people’s flaws.23.Finally, do you have any questions to ask me?I’ll finish the way I started, with one of the most common questions asked in interviews.This directly relates to the research you’ve done on the company and also gives you a chance to show how eager and prepared you are.You’ll probably want to ask about benefits if they haven’t been covered already.A good generic one is “how soon could I start, if I were offered the job of course.” You may also ask what you’d be working on.Specifically, in the role you’re applying for and how that affects the rest of the company.Always have questions ready, greeting this one with a blank stare is a rotten way to finish your interview.Good luck and happy job hunting.ponder for a moment, and then ask your interviewer “what aspect of your job do you find most challenging”.I would ask the interviewer, “Why do you like to work here?” 24.Where do you want to be in 5 to years?They dont want to hear in the same job you are interviewing for.Ultimately, the HR people are searching for someone who can handle the job now, and has the potential to grow into a high level management job in the future.Do you have those goals too?25.Would you rather work for a big company or a small one?Favorite answer: I’d treat any company like it was my own regardless.Total ownership of the situation can get you a long way.General , the worst answer was “I don’t know.” I’ve since learned that “it depends,” with a couple of examples, isperfectly appropriate第二篇:记者笔试面试参考题目及答案记者专业题1、简述新闻工作的内涵和特点。

英语招聘笔试题库及答案

英语招聘笔试题库及答案

英语招聘笔试题库及答案一、选择题1. The company is looking for candidates who are proficient in ________.A) EnglishB) ChineseC) SpanishD) French答案:A2. Which of the following is NOT a requirement for the job position?A) Good communication skillsB) A bachelor's degreeC) At least 3 years of experienceD) The ability to speak multiple languages答案:D二、填空题1. The employee is expected to have a strong command of________.[答案] English2. The job requires a minimum of ________ years of relevant experience.[答案] 3三、阅读理解题Read the following passage and answer the questions.Passage:The company is seeking a new employee with excellent English language skills. The candidate must have a bachelor's degree and at least three years of experience in a related field.The ideal candidate should be able to communicate effectively and work well in a team.Questions:1. What is the minimum educational requirement for the job? [答案] A bachelor's degree2. How many years of experience are required for the position? [答案] At least three years四、翻译题1. 请将以下句子翻译成英文:“我们正在寻找具有出色英语沟通能力的候选人。

英语面试测试题目及答案

英语面试测试题目及答案

英语面试测试题目及答案一、听力理解(共10分)1. What is the weather like today?A. SunnyB. RainyC. CloudyD. Snowy答案:A2. What does the man suggest they do after work?A. Go to the moviesB. Go to a concertC. Go for a walkD. Stay at home答案:C二、词汇与语法(共20分)3. The teacher asked the students to _______ their homework on time.A. hand inB. hand outC. hand overD. hand down答案:A4. I don't think it is necessary to _______ the whole book, just read the important parts.A. go throughB. go byC. go withD. go against答案:A三、阅读理解(共30分)5. According to the passage, what is the main reason for people to travel?A. To relaxB. To explore new placesC. To meet new peopleD. To escape from daily routine答案:D6. What is the author's opinion about online shopping?A. It is convenient but lacks the experience of physical shopping.B. It is time-consuming and not as efficient as physical shopping.C. It is the only way to shop in the future.D. It is better than physical shopping in every aspect.答案:A四、完形填空(共20分)7. The _______ of the company was very impressed by the newemployee's performance.A. managerB. directorC. supervisorD. president答案:D8. She _______ to the meeting even though she was feeling unwell.A. attendedB. joinedC. participatedD. took part答案:A五、翻译(共20分)9. 这个项目需要团队合作和创新思维。

英语面试笔试常用题

英语面试笔试常用题

英语面试笔试常用题一、自我介绍。

这可是面试里超级常见的部分呢。

你就简单说说自己是谁,从哪儿来,现在在干啥,还有你的一些小特长或者独特的经历就好啦。

比如说:“Hi, my name is [你的名字]. I'm from [你的家乡], a really beautiful place. Right now, I'm a college student majoring in [你的专业]. I'm a super outgoing person and I love making friends. One of my coolest experiences was when I participated in a volunteer activity last year. We went to a mountain village to teach the kids there. It was so rewarding and I learned a lot from those innocent children.”二、教育背景。

他们可能会问你关于你的学校和专业的情况。

你就可以像这样回答:“I study at [你的大学名字], which is a really great university with a long history and a beautiful campus. My major is [你的专业], and I chose it because I've always been interested in [你对这个专业感兴趣的原因]. During my study, I've learned a lot of useful knowledge and skills. For example, I'm good at [列举一些你擅长的专业相关技能], which I think will be very helpful for this job.”三、工作经验(如果有)要是你有工作经验,那可就有得聊啦。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C/C++ Programming interview questions and answersBy Satish Shetty, July 14th, 2004What is encapsulation??Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates the internal complexity of an object's operation from the rest of the application. For example, a client component asking for net revenue from a business object need not know the data's origin.What is inheritance?Inheritance allows one class to reuse the state and behavior of another class. The derived class inherits the properties and method implementations of the base class and extends it by overriding methods and adding additional properties and methods.What is Polymorphism??Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.You can use implementation inheritance to achieve polymorphism in languages such as C++ and Java.Base class object's pointer can invoke methods in derived class objects.You can also achieve polymorphism in C++ by function overloading and operator overloading.What is constructor or ctor?Constructor creates an object and initializes it. It also creates vtable for virtual functions. It is different from other methods in a class.What is destructor?Destructor usually deletes any extra resources allocated by the object.What is default constructor?Constructor with no arguments or all the arguments has default values.What is copy constructor?Constructor which initializes the it's object member variables ( by shallow copying) with another object of the same class. If you don't implement one in your class then compiler implements one for you.for example:Boo Obj1(10); // calling Boo constructorBoo Obj2(Obj1); // calling boo copy constructorBoo Obj2 = Obj1;// calling boo copy constructorWhen are copy constructors called?Copy constructors are called in following cases:a) when a function returns an object of that class by valueb) when the object of that class is passed by value as an argument to a functionc) when you construct an object based on another object of the same classd) When compiler generates a temporary objectWhat is assignment operator?Default assignment operator handles assigning one object to another of the same class. Member to member copy (shallow copy)What are all the implicit member functions of the class? Or what are all the functions which compiler implements for us if we don't define one.??default ctorcopy ctorassignment operatordefault destructoraddress operatorWhat is conversion constructor?constructor with a single argument makes that constructor as conversion ctor and it can be used for type conversion.for example:class Boo{public:Boo( int i );};Boo BooObject = 10 ; // assigning int 10 Boo objectWhat is conversion operator??class can have a public method for specific data type conversions.for example:class Boo{double value;public:Boo(int i )operator double(){return value;}};Boo BooObject;double i = BooObject; // assigning object to variable i of type double. now conversion operator gets called to assign the value.What is diff between malloc()/free() and new/delete?malloc allocates memory for object in heap but doesn't invoke object's constructor to initiallize the object.new allocates memory and also invokes constructor to initialize the object.malloc() and free() do not support object semanticsDoes not construct and destruct objectsstring * ptr = (string *)(malloc (sizeof(string)))Are not safeDoes not calculate the size of the objects that it constructReturns a pointer to voidint *p = (int *) (malloc(sizeof(int)));int *p = new int;Are not extensiblenew and delete can be overloaded in a class"delete" first calls the object's termination routine (i.e. its destructor) and then releases the space the object occupied on the heap memory. If an array of objects was created using new, then delete must be told that it is dealing with an array by preceding the name with an empty []:-Int_t *my_ints = new Int_t[10];...delete []my_ints;what is the diff between "new" and "operator new" ?"operator new" works like malloc.What is difference between template and macro??There is no way for the compiler to verify that the macro parameters are of compatible types. The macro is expanded without any special type checking.If macro parameter has a postincremented variable ( like c++ ), the increment is performed two times.Because macros are expanded by the preprocessor, compiler error messages will refer to the expanded macro, rather than the macro definition itself. Also, the macro will show up in expanded form during debugging.Macro:#define min(i, j) (i < j ? i : j)template:template<class T>T min (T i, T j){return i < j ? i : j;}What are C++ storage classes?autoregisterstaticexternauto: the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that blockregister: a type of auto variable. a suggestion to the compiler to use a CPU register for performancestatic:a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins executionextern: a static variable whose definition and placement is determined when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.What are storage qualifiers in C++ ?They are..constvolatilemutableConst keyword indicates that memory once initialized, should not be altered by a program. volatile keyword indicates that the value in the memory location can be altered even though nothing in the programcode modifies the contents. for example if you have a pointer to hardware location that contains the time, where hardware changes the value of this pointer variable and not the program. The intent of this keyword to improve the optimization ability of the compiler.mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.{char name[80];mutable double salary;}const data MyStruct = { "Satish Shetty", 1000 }; //initlized by complierstrcpy ( , "Shilpa Shetty"); // compiler errorMyStruct.salaray = 2000 ; // complier is happy allowedWhat is reference ??reference is a name that acts as an alias, or alternative name, for a previously defined variable or an object.prepending variable with "&" symbol makes it as reference.for example:int a;int &b = a;What is passing by reference?Method of passing arguments to a function which takes parameter of type reference.for example:void swap( int & x, int & y ){int temp = x;x = y;y = temp;}int a=2, b=3;swap( a, b );Basically, inside the function there won't be any copy of the arguments "x" and "y" instead they refer to original variables a and b. so no extra memory needed to pass arguments and it is more efficient.When do use "const" reference arguments in function?a) Using const protects you against programming errors that inadvertently alter data.b) Using const allows function to process both const and non-const actual arguments, while a function without const in the prototype can only accept non constant arguments.c) Using a const reference allows the function to generate and use a temporary variable appropriately.When are temporary variables created by C++ compiler?Provided that function parameter is a "const reference", compiler generates temporary variable in following 2 ways.a) The actual argument is the correct type, but it isn't Lvaluedouble Cube(const double & num){num = num * num * num;return num;}double temp = 2.0;double value = cube(3.0 + temp); // argument is a expression and not a Lvalue;b) The actual argument is of the wrong type, but of a type that can be converted to the correct type long temp = 3L;double value = cuberoot ( temp); // long to double conversionWhat is virtual function?When derived class overrides the base class method by redefining the same function, then if client wants to access redefined the method from derived class through a pointer from base class object, then you must define this function in base class as virtual function.class parent{void Show(){cout << "i'm parent" << endl;}};class child: public parent{void Show(){cout << "i'm child" << endl;}};parent * parent_object_ptr = new child;parent_object_ptr->show() // calls parent->show() inow we goto virtual world...class parent{virtual void Show(){cout << "i'm parent" << endl;}};class child: public parent{void Show(){cout << "i'm child" << endl;}};parent * parent_object_ptr = new child;parent_object_ptr->show() // calls child->show()What is pure virtual function? or what is abstract class?When you define only function prototype in a base class without implementation and do the complete implementation in derived class. This base class is called abstract class and client won't able to instantiate an object using this base class.You can make a pure virtual function or abstract class this way..class Boo{void foo() = 0;}Boo MyBoo; // compilation errorWhat is Memory alignment??The term alignment primarily means the tendency of an address pointer value to be a multiple of some power of two. So a pointer with two byte alignment has a zero in the least significant bit. And a pointer with four byte alignment has a zero in both the two least significant bits. And so on. More alignment means a longer sequence of zero bits in the lowest bits of a pointer.What problem does the namespace feature solve?Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library's external declarations with a unique namespace that eliminates the potential for those collisions.namespace [identifier] { namespace-body }A namespace declaration identifies and assigns a name to a declarative region.The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.What is the use of 'using' declaration?A using declaration makes it possible to use a name from a namespace without the scope operator.What is an Iterator class?A class that is used to traverse through the objects maintained by a container class. There are five categories of iterators: input iterators, output iterators, forward iterators, bidirectional iterators, random access. An iterator is an entity that gives access to the contents of a container object without violating encapsulation constraints. Access to the contents is granted on a one-at-a-time basis in order. The order can be storage order (as in lists and queues) or some arbitrary order (as in array indices) or according to some ordering relation (as in an ordered binary tree). The iterator is a construct, which provides an interface that, when called, yields either the next element in the container, or some value denoting the fact that there are no more elements to examine. Iterators hide the details of access to and update of the elements of a container class. Something like a pointer.What is a dangling pointer?A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.What do you mean by Stack unwinding?It is a process during exception handling when the destructor is called for all local objects in the stack between the place where the exception was thrown and where it is caught.Name the operators that cannot be overloaded??sizeof, ., .*, .->, ::, ?:What is a container class? What are the types of container classes?A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container.What is inline function??The __inline keyword tells the compiler to substitute the code within the function definition for every instance of a function call. However, substitution occurs only at the compiler's discretion. For example, the compiler does not inline a function if its address is taken or if it is too large to inline.What is overloading??With the C++ language, you can overload functions and operators. Overloading is the practice of supplying more than one definition for a given function name in the same scope.- Any two functions in a set of overloaded functions must have different argument lists.- Overloading functions with argument lists of the same types, based on return type alone, is an error.What is Overriding?To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list. The definition of the method overriding is:· Must have same method name.· Must have same data type.· Must have same argument list.Overriding a method means that replacing a method functionality in child class. To imply overriding functionality we need parent and child classes. In the child class you define the same method signature as one defined in the parent class.What is "this" pointer?The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.When a nonstatic member function is called for an object, the address of the object is passed as a hidden argument to the function. For example, the following function callmyDate.setMonth( 3 );can be interpreted this way:setMonth( &myDate, 3 );The object's address is available from within the member function as the this pointer. It is legal, though unnecessary, to use the this pointer when referring to members of the class.What happens when you make call "delete this;" ??The code has two built-in pitfalls. First, if it executes in a member function for an extern, static, or automatic object, the program will probably crash as soon as the delete statement executes. There is no portable way for an object to tell that it was instantiated on the heap, so the class cannot assert that its object is properly instantiated. Second, when an object commits suicide this way, theusing program might not know about its demise. As far as the instantiating program is concerned, the object remains in scope and continues to exist even though the object did itself in. Subsequent dereferencing of the pointer can and usually does lead to disaster.You should never do this. Since compiler does not know whether the object was allocated on the stack or on the heap, "delete this" could cause a disaster.How virtual functions are implemented C++?Virtual functions are implemented using a table of function pointers, called the vtable. There is one entry in the table per virtual function in the class. This table is created by the constructor of the class. When a derived class is constructed, its base class is constructed first which creates the vtable. If the derived class overrides any of the base classes virtual functions, those entries in the vtable are overwritten by the derived class constructor. This is why you should never call virtual functions from a constructor: because the vtable entries for the object may not have been set up by the derived class constructor yet, so you might end up calling base class implementations of those virtual functionsWhat is name mangling in C++??The process of encoding the parameter types with the function/method name into a unique name is called name mangling. The inverse process is called demangling.For example Foo::bar(int, long) const is mangled as `bar__C3Fooil'.For a constructor, the method name is left out. That is Foo::Foo(int, long) const is mangled as `__C3Fooil'.What is the difference between a pointer and a reference?A reference must always refer to some object and, therefore, must always be initialized; pointers do not have such restrictions. A pointer can be reassigned to point to different objects while a reference always refers to an object with which it was initialized.How are prefix and postfix versions of operator++() differentiated?The postfix version of operator++() has a dummy parameter of type int. The prefix version does not have dummy parameter.What is the difference between const char *myPointer and char *const myPointer?Const char *myPointer is a non constant pointer to constant data; while char *const myPointer is a constant pointer to non constant data.How can I handle a constructor that fails?throw an exception. Constructors don't have a return type, so it's not possible to use return codes. The best way to signal constructor failure is therefore to throw an exception.How can I handle a destructor that fails?Write a message to a log-file. But do not throw an exception.The C++ rule is that you must never throw an exception from a destructor that is being called during the "stack unwinding" process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() and the } catch (Foo e) { will get popped. This is called stack unwinding.During stack unwinding, all the local objects in all those stack frames are destructed. If one ofthose destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) { where it was originally headed? Should it ignore the Foo and look for a } catch (Bar e) { handler? There is no good answer -- either choice loses information.So the C++ language guarantees that it will call terminate() at this point, and terminate() kills the process. Bang you're dead.What is Virtual Destructor?Using virtual destructors, you can destroy objects without knowing their type - the correct destructor for the object is invoked using the virtual function mechanism. Note that destructors can also be declared as pure virtual functions for abstract classes.if someone will derive from your class, and if someone will say "new Derived", where "Derived" is derived from your class, and if someone will say delete p, where the actual object's type is "Derived" but the pointer p's type is your class.Can you think of a situation where your program would crash without reaching the breakpoint which you set at the beginning of main()?C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered.Name two cases where you MUST use initialization list as opposed to assignment in constructors.Both non-static const data members and reference data members cannot be assigned values; instead, you should use initialization list to initialize them.Can you overload a function based only on whether a parameter is a value or a reference?No. Passing by value and by reference looks identical to the caller.What are the differences between a C++ struct and C++ class?The default member and base class access specifiers are different.The C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base class inheritance, and a class defaults to the private access specifier and private base class inheritance.What does extern "C" int func(int *, Foo) accomplish?It will turn off "name mangling" for func so that one can link to code compiled by a C compiler. How do you access the static member of a class?<ClassName>::<StaticMemberName>What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?Multiple Inheritance is the process whereby a child can be derived from more than one parent class. The advantage of multiple inheritance is that it allows a class to inherit the functionality of more than one base class thus allowing for modeling of complex relationships. The disadvantage of multiple inheritance is that it can lead to a lot of confusion(ambiguity) when two base classes implement a method with the same name.What are the access privileges in C++? What is the default access level?The access privileges in C++ are private, public and protected. The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class. Protected members are accessible by the class itself and it's sub-classes. Public members of a class can be accessed by anyone.What is a nested class? Why can it be useful?A nested class is a class enclosed within the scope of another class. For example:// Example 1: Nested class//class OuterClass{class NestedClass{// ...};// ...};Nested classes are useful for organizing code and controlling access and dependencies. Nested classes obey access rules just like other parts of a class do; so, in Example 1, if NestedClass is public then any code can name it as OuterClass::NestedClass. Often nested classes contain private implementation details, and are therefore made private; in Example 1, if NestedClass is private, then only OuterClass's members and friends can use NestedClass.When you instantiate as outer class, it won't instantiate inside class.What is a local class? Why can it be useful?local class is a class defined within the scope of a function -- any function, whether a member function or a free function. For example:// Example 2: Local class//int f(){class LocalClass{// ...};// ...};Like nested classes, local classes can be a useful tool for managing code dependencies.Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?No. It is specified in the definition of the copy constructor itself. It should generate an error if a programmer specifies a copy constructor with a first argument that is an object and not a reference.。

相关文档
最新文档