C c++ java interview questions with answers free download

c c++ java interview questions with answers free download

  • Java Interview Questions and Answers () - InterviewBit
  • Top 39 C++ Interview Questions () - javatpoint
  • C Programming Interview Questions () - javatpoint
  • Re: C And C++ Interview Questions And Answers PDF Download
  • Java language was developed in such a way that it does not depend on any hardware or software due to the fact that the compiler compiles the code and then converts it to platform-independent byte code which can be run on multiple systems. Java supports primitive data types - byte, boolean, char, short, int, float, long, and double and hence it is not a pure object-oriented language.

    Pointers are quite complicated and unsafe to use by beginner programmers. Java focuses on code simplicity, and the usage of pointers can make it challenging. Pointer utilization can also cause potential errors. Moreover, security is also compromised if pointers are used because the users can directly access memory with the help of pointers. Thus, a certain level of abstraction is furnished by not including pointers in Java.

    Moreover, the usage of pointers can make the procedure of garbage collection quite slow and erroneous. Java makes use of references as these cannot be manipulated, unlike pointers. Instance variables are those variables that are accessible by all the methods in the class. They are declared outside the methods and inside the class. These variables describe the properties of an object and remain bound to it at any cost.

    All the objects of the class will have their copy of the variables for utilization. If any modification is done on these variables, then only that instance will be impacted by it, and all other class instances continue to remain unaffected.

    Java Interview Questions and Answers () - InterviewBit

    Local variables are those variables present within a block, function, or constructor and can be accessed only inside them. The utilization of the variable is restricted to the block scope. Infinite loops are those loops that run infinitely without any breaking conditions. Some examples of consciously declaring infinite loop is:. Constructor overloading is the process of downlowd multiple constructors in the class consisting of the same name with a difference in the constructor parameters. Depending upon the number of parameters and their corresponding anxwers, distinguishing of the different types of constructors is done by the compiler.

    Three constructors are defined here but they differ on the basis of parameter type and their numbers. In Java, method overloading is made possible by introducing different methods in the same class consisting of the same name. Still, all the functions answets in the number or type of parameters. It takes place inside a class and enhances program readability.

    The only difference in the return type of the method does not promote method overloading. The following example will furnish you with a clear picture of it. Both the functions have the same name but differ in the number of arguments. The first method calculates the area of the rectangle, whereas the second method calculates the area of a cuboid. Method overriding is the concept in which two methods having the same method signature are present in two different classes in which an inheritance relationship is present.

    A particular method implementation already present in the base class is possible for the derived class by using method overriding. Both class methods have the name walk and the same parameters, distance, and time. If the derived class method is called, then the base class method walk gets overridden by that of the derived class. Yes, multiple catch blocks can exist but specific approaches should come prior to the general approach because only the first catch block satisfying the catch condition is executed.

    The given code illustrates the same:. Final: If any restriction is required for classes, variables, or methods, the final keyword comes in handy. Inheritance of a final class and overriding of a final method is restricted by the use of the final keyword. The variable value becomes fixed after incorporating the final keyword. Finally: It is the block present in a program where all the codes written inside it get executed irrespective of handling of exceptions. Finalize: Prior to the garbage collection of answres object, the finalize method is called so that the clean-up activity is implemented.

    Top 39 C++ Interview Questions () - javatpoint

    There can be two or more static rree in a class with the same name but differing input parameters. The main objective of this process is to free up the memory space occupied by the unnecessary and unreachable objects during the Java program execution by deleting those unreachable objects. The statement in the context is completely False. The static methods have no relevance with the objects, and these methods are of the class level. In the case of a child class, a static method with a method signature exactly like that of the parent class can exist without even throwing any compilation error.

    The phenomenon mentioned here is popularly known as method hiding, and overriding is certainly not possible. Private method overriding is unimaginable because the queztions of the private method is restricted to the interviw class only. As anawers result, only hiding can be facilitated and not overriding. Although both HashSet and TreeSet are not synchronized and ensure that duplicates are not present, there are certain properties that distinguish a HashSet from a TreeSet.

    In Java, a string is basically immutable i. After its declaration, it continues to stay in the string pool as quewtions as it is not removed in the form of garbage. In other words, a string resides in the heap section of the memory for an unregulated and unspecified time interval after string value processing is executed. As a result, vital information can be stolen for pursuing harmful activities by hackers if a memory dump is illegally accessed by them.

    Such risks can be eliminated by using mutable objects or structures like character arrays for storing any variable. After the work of the frde array variable is done, the variable can be configured to blank at the same instant. Consequently, it helps in saving heap memory and also gives no chance to the hackers to extract vital data. However, when the object is passed in any method, the address of the value is passed due to the nature of object handling in Java. When an object is passed, a copy of the reference is created by Java and that is passed to the method.

    The objects point to the same memory answerx.

    c c++ java interview questions with answers free download

    StringBuffer is wifh and dynamic in nature whereas String is immutable. Hence, in the cases of a lot of updates, it is always preferred to use StringBuffer as it will reduce the overhead of the creation of multiple String objects in the string free. There wouldn't be any compilation error. Questions d can't compile as the compiler says that the java has been already defined inside the class. When downloxd exception occurs, first it searches to locate the matching catch block.

    In case, the matching catch block is located, then that block would be executed. Else, the exception propagates through the method call stack and goes into the caller method where the process of matching the catch block is performed. This propagation happens until the matching catch block is found. If the match is not found, then the program gets terminated in the main method. No, it is not necessary for a catch block to be present after a try block.

    If the exceptions likelihood is more, then they should be declared using the throws clause of the method. Yes, the concept can be termed as constructor chaining and can be achieved using this. In the case of ArrayList, data storing in the form of primitive data types like int, float, etc. Thus, storing of actual download or non-primitive data types answers Integer, Double, etc.

    However, the same does not apply to the arrays. Object or primitive type values can be stored in arrays in contiguous memory locations, hence every element does not require any reference to the next element. In ansders above example, inheritance is followed. Now, xownload modifications are done to the Top class like this:. If the new implementation of the Top class is followed, a compile-time error is bound c++ occur in the Bottom class.

    Incompatible return type is there for the Top. Changes have to be made to either the Top or the Bottom class to ensure compatibility. However, the composition c++ can be utilized to solve the given problem:. When a String is formed as java literal with the assistance of an assignment operator, it makes its way into aith String constant pool so that String Interning can take place.

    This same object in the uava will be referenced by a different String if the content is the same for both of them. The checking function will return true c+ the same content is referenced by both the variables. Conversely, when a String formation questuons place with the help of a new operator, interning does not take place. The object gets created in the heap memory even if the same content object is present. The checking function will return false as the same content is not referenced by both the variables.

    Yes, it is possible for the program to go out of memory in spite of the presence of a garbage collector. Garbage collection assists in recognizing and eliminating those objects which are not required questions the program anymore, in order to downloaf up the resources used by them. In a program, if an object is unreachable, then the execution questiond garbage collection takes place with respect to that object.

    If the amount of memory required for answers a new object is not sufficient, then memory is released for qkestions objects which are no longer in the scope with the help of a garbage ahswers. The memory limit is exceeded for the with when the memory released is not enough for creating new objects.

    Moreover, exhaustion of the heap memory takes place if with are created downloax such a manner that they remain in the scope and consume memory. The developer should make sure to dereference the object after its work is accomplished. Although the garbage collector endeavors its level best to reclaim memory as much as possible, memory limits can still be exceeded.

    Concurrent execution of different processes is made possible by synchronization. When a particular resource is shared between many threads, interview may arise in which multiple threads require the same shared resource. Synchronization assists in resolving the issue and interview resource is shared by a single thread at a time. For example, you have a URL and you have to find out the number of requests made to it.

    Two simultaneous requests can make the count erratic. If a thread Thread1 views the count as 10, it will be increased by 1 to Simultaneously, if another thread Thread2 views the count as 10, it will be increased by 1 to Thus, inconsistency in count values takes place because the expected final value is 12 but the actual final value we get will be Now, frree function increase is made synchronized so that simultaneous accessing cannot take place.

    If a thread Thread1 views the count as 10, it will be increased frse 1 to 11, then the thread Thread2 will view the count as 11, it will be increased by 1 to Iwth, consistency in count qurstions takes place. It is possible to import a class or package more than once, however, it is redundant jav the JVM internally loads the package or class only once. This is a big NO. We need to understand that the importing of the sub-packages of a package needs to be done explicitly.

    The control of the program post System. Marker interfaces, also known as tagging interfaces are those interfaces that have no methods and constants defined in them. They are there for helping the compiler and JVM to get run time-related information regarding the objects. Care download be taken while initializing through this method as the method involves the creation of anonymous inner classes which can cause problems during the garbage collection or serialization processes and may free result in memory leaks.

    Here are the list of most frequently asked C and C++ Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. Q1. What are the features in c programming? C programming language supports multiple tools.kmorgan.coted Reading Time: 8 mins. Java Basic Interview Questions 1. Why is Java a platform independent language? Java language was developed in such a way that it does not depend on any hardware or software due to the fact that the compiler compiles the code and then converts it to platform-independent byte code which can be run on multiple systems. Aug 23,  · The Best Answers to Tough Interview Questions How to face interview tricks. Attached Files for Direct Download. File Name: C,C++ Interview Q&tools.kmorgan.co File Size: KB. Total Downloads: * Click on the 'file icon' or 'file name' to start downloading.

    Now if questionz string contained supplementary characters, the length function would count that as 2 units and the result of the length function would not be as per what is expected. As per the java documentation, it is expected, but as per the real logic, it is inaccurate. But the question has the character literals single quotes being used which is why concatenation wouldn't occur. The corresponding ASCII values of each character would be added and the result of that sum would be printed.

    First Approach: Set the object references to null once the object creation purpose is served. Second Approach: Point the reference variable to another object. The above syntax tells that p is a pointer variable that holds the address number of a given data type value. When we assign a '0' value to a pointer of any type, then it becomes a Null pointer. A pointer which can access all the 16 segments whole residence memory of RAM is known as far pointer.

    A far pointer is a bit pointer that obtains information outside the memory in a given section. In the above example, initially memory is allocated to the pointer variable ptr, and then the memory is deallocated from the pointer variable. Now, javaa variable, i.

    Top C and C++ Interview Questions and Answers [UPDATED]

    The problem of a dangling questions can be overcome by assigning a NULL value to the dangling pointer. Let's interview this through an example:. In the above example, after deallocating the memory from a pointer variable, ptr is assigned to a NULL value. This means that ptr does not point to any memory location. Therefore, it is no longer a dangling pointer. In case of a pointer to pointer concept, one pointer refers to the address of another pointer.

    The pointer to pointer is a chain of pointers. Generally, the pointer contains the address of a variable. The pointer to pointer contains the address of a first pointer. Let's understand this concept through an example:. In the above example, pptr is a double pointer pointing to the address of the ptr variable and ptr points to the address of 'a' variable. In the above example, the value of a and b gets corrupted, and only variable ch shows the actual output.

    This is because all the members of a union share the common memory space. Hence, the variable ch whose value is currently updated. In C, every c++ variable of a function is known as an automatic auto variable. Variables which are declared inside the function block are known as a local variable. The local variables are also known as an auto variable. It is optional to use an auto keyword before the data type of a variable.

    If no value is stored in the local variable, then it consists of a garbage value. The sprintf stands for "string print. It transfers the data to the buffer. It returns the total number of characters present in the string. But, if we use define, we can compile and run a C program without using the main function.

    For example:. The Token is an identifier. It can be constant, keyword, string literal, etc. A token is the smallest individual unit in a program. C has the following tokens:. The argument passed to the main function while executing the program is known as command line argument. The getch function reads a single character from the keyboard. It doesn't use any buffer, so entered data will not be with on the output screen.

    The getche function reads a single character from the keyword, free data is displayed on the java screen. In the above example, the value entered through a getch function is not displayed on the download while the value entered through a getche function is displayed on the screen. A near pointer doesn't have explicit selector whereas far, and huge pointers have explicit selector.

    When you perform pointer arithmetic on the far pointer, the selector is not modified, but in case of a huge pointer, it can be modified. These are the non-standard keywords and implementation specific. These are irrelevant in a modern platform. The typecasting is a process of converting one data type into another answers known as typecasting.

    C Programming Interview Questions () - javatpoint

    If we want to store intrrview floating type value to an int type, then we jaava convert the data type into another data type explicitly. The fopen function is used to open file whereas fclose is used to close file. Yes, by holding the base address of array into a pointer, we can access the array using a pointer. JavaTpoint offers too many high quality services.

    If we pass by reference that means we are not creating new object, we are passing reference of existing object. Copy constructor itself is a function, if we pass argument by value, it will again call copy constructor, thereby making a chain of calls. Function overriding is the re-definition of a function from base class to derived class i.

    To overcome such a scenario we make the base class function which is overridden as virtual. My marking function is virtual. The compiler will resolve that call at run time. Now if mark function as virtual, answers understands mapping need to be done at run time instead of compile time. So when suestions b2 is created.

    It sees object is of class B, questions maps with the object of B class andwers if we mark a base class function as virtual instead of class base xownload fun it will call derived class fun. Virtual functions is a member function defined in the base class c++ overridden in the derived class. We use the virtual keyword for that. When an object is with for a classeach object contains its own copy of member variables and a unique copy of member functions.

    To assign each object a unique copy of member variables javx, bit should be allocated to a unique address. A friend function is given special privilege to access private and protected members of the class. We can make a function friend by adding a javz friend in the beginning of the function. It can be a function of some other class or it can be global also. When static is given with class variables, interview variables belong to the class, instead of belonging it with the object.

    Only one copy will be shared java all objects. Answers declared with function, they can be called with an object, directly with class names they can be called. Yes, frer constructor c+ private. If downlaod have such scenarios where we want download make only one object per class. C++ of object is decided at compile time and virtual calls are resolved at run time.

    These conditions contradict each other. If we make a constructor virtual, we wont be able to find out type of object at compile time, so compiler will generate an error. A class having at least one pure virtual function, becomes abstract class, downloa its object cant be created. If a function is declared pure virtual in base free, it must be overridden in derived class. If not questions in derived class, then derived class also becomes abstract class.

    Dynamic creation of memory means rather than aith memory at run time, memory is java to object at run time. When memory with allocated using a new operator, the compiler allocated one block of memory extra to anzwers how much memory needs to be allocated. When memory is allocated to ptr, 8 bytes, at beginning compiler says how much memory to be allocated then add extra 8 byes sith ptr. As soon as we call delete ptrthe compiler goes to the ptr location, checks how much memory needs to be freed, that corresponding blocks it frees and moves them back to free store.

    Preprocessor handles questinos directives such as macros, file inclusion, conditional compilation. It replaces it with actual piece of code. If program contains large piece of independent code. Its always a good practice to split code in different header file and include that header file separately. Preprocessor directives begin with a hash. Preprocessor directives are the instructions given to the compiler. Comments are used to understand the program flow and its explains the code written in the program.

    All the blocks are of same size. The concept behind the encapsulation and data hiding restrict the non-member function from accessing the znswers members of the class by using the friend keyword. The private members of one class can be accessed from the member functions Of another class by making them friends. Used to initialize the data members of a class with different values when they are created. This is achieved by passing arguments to the constructor functions when the objects are created.

    Simply defined as to create new definitions for operators. NOTE : you can use an abstract class only act as a base class intervview deriving other classes but does not create objects. Manipulator function is special stream functions that change certain characteristics of input and output. All the manipulator functions questinos are defined in the. It is a special pointer that exists for a class while answerw non-static Member function is executing.

    It is used to access the address of the Class itself and may return data items to the caller. Each stream is associated with a particular class that contains member functions and interview for dealing with that particular kind of data flow. List of frequently asked IBM Explore Now! Interview Questions. What are the features in c programming? C programming language supports multiple features. They are Interrview Programming Language: C programming supports high-level features like Pointers, Structures data structures and as well as it will supports assembly code also so we conclude c as a middle level programming language.

    Structured oriented programming Language : C program is structure oriented programming language means it will execute the statement in sequence Modularity: In c programming language we can reduce the more line number of code by using modularity Portability: C programming language is platform-independent means with minor modifications we can reuse the code on different platforms also. Powerful Data Structure: With the help of data structures we can implement the complex application easily. What are the data types in c?

    Data types divided into two types. They are Free anewers types User defined data types Predefined Data types: Int, char, float and double are the predefined data types User-defined data types: Arrays, Pointers, strings, and structures are user-defined data types. Types of errors in c? Errors in c programming are divided in two answer. What are the Compile Time Errors? What are the Run time errors? Here we can discuss the compile-time they are Segmentation Fault: Un authorized memory access called as segmentation fault Bus Error: Memory is not at all existing still programmer trying to access it.

    What is a function in c? Types of Functions? What are Pre Defined Download What is User Defined Functions? They are below Function declaration Function definition Function call. Control Statements or Control Flow? Control statements are divided into three types. Conditional statements in c? These statements are decision making statements in source code. This are several types if statements if-else statement downlod if —else statement nested frree statement switch-case statement.

    Iterative loop statements in c?

    Re: C And C++ Interview Questions And Answers PDF Download

    When we are going to use repeated code we will use iterative statements. These are several types for loop While loop do-while loop. Jump statements in c? These are several types break continue goto. What is a header file? What are the translator in c? What is assembler? It convert high level lang. Innterview takes the program as a whole and converts it into object code before execution. Char-character data type. Float-floating point value. Double-a double precision floting point value.

    Void-valueless special purpose type. Static variable static variable are declared by writing keyword static in front of the declaration. Can we declare variable anywhare in c? How many keywords used in c? What is register variable in c? Questiobs is extern in c? What are the token in c program? Difference between declaration and definition? Does c have a boolean variable type? What is the basic component of the IEEE floating point?

    Why we use trigraph character? What is the keyword? What is constant? What is a function? The algorithm provides a step by step procedure on how a solution can be derived.

    3 thoughts on “C c++ java interview questions with answers free download”

    1. Matt Wright:

      Do you have what it takes to ace a Java Interview? We are here to help you in consolidating your knowledge and concepts in Java. The following article will cover all the popular Java interview questions for freshers as well as experienced candidates in depth.

    2. Joseph Ross:

      It was released in Initially, Stroustrup called the new language "C with classes".

    3. Cedric Edwards:

      We hope these interview questions and answers are useful and will help you to get the best job in industry. These are top interview questions and answers, prepared by our institute experienced trainers.

    Add a comments

    Your e-mail will not be published. Required fields are marked *