Saturday, 8 August 2020

Top 30 OOPS Interview Questions And Answers

Top 30 OOPS Interview Questions And Answers


Q1. What is a class ?

ANS : A class is simply a representation of a type of object it is the blueprint slash plan slash template that described the details of an object

 

Q2. What is an object ?

ANS : Object is termed as an instance of a class and it has its own State behavior and identity

 

Q3. What is encapsulation ?

ANS : Encapsulation is an attribute of an object and it contains all data which is hidden that hidden data can be restricted to the members of that class levels are public protected private internal and protected 

 

Q4. What is polymorphism ?

ANS : Polymorphism is nothing but assigning behavior or value in a subclass to something that was already declared in the main class simply polymorphism takes more than one form 


Q5. What is inheritance ?

ANS : Inheritance is a concept where one class shares the structure and behavior defined in another class if inheritance applied on one class is called single inheritance and if it depends on multiple classes then it is called multiple inheritance none

 

Q6. What are manipulators ?

ANS : Manipulators are the functions which can be used in conjunction with the insertion and extraction operators on an object

 

Q7. Define a constructor ?

ANS : Constructor is a method used to initialize the state of an object and it gets invoked at the time of object creation rules for constructor , name should be same as class name constructor must have no return type

 

Q8. What is in line function ?

ANS : Inline function is a technique used by the compilers and instructs to insert complete body of the function wherever that function is used in the program source code

 

Q9. What is a virtual function ?

ANS : Virtual function is a member function of class and its functionality can be overridden in its derived class this function can be implemented by using a keyword called virtual and it can be given during function declaration virtual function can be achieved in C++ and it can be achieved in C language by using function pointers or pointers to function

 

Q10. What is friend function ?

ANS : Friend function is a friend of a class that is allowed to access to public private or protected data in that same class if the function is defined outside the class cannot access such information friend can be declared anywhere in the class declaration and it cannot be effected by access control keywords like private public or protected

 

Q11. What is function overloading ?

ANS : Function overloading is defined as a normal function but it has the ability to perform different tasks it allows creation of several methods with the same name which differ from each other by type of input and output of the function 

 

Q12. What is operator overloading ?

ANS : Operator overloading is a function where different operators are applied and depends on the arguments operator asterisk can be used to pass through the function and it has their own proceedings to execute sixteen what is an abstract class an abstract class is a class which cannot be instantiated creation of an object is not possible with abstract class but it can be inherited an abstract class can contain only abstract method Java allows only abstract method in abstract class while for other language it allows non abstract method as well

 

Q13. What is a ternary operator ?

ANS : Ternary operator is said to be an operator which takes three arguments arguments and results are of different data types and it is depends on the function ternary operator is also called as conditional operator 

 

Q14. What is the use of finalize method ?

ANS : Finalize method helps to perform cleanup operations on the resources which are not currently used finalize method is protected and it is accessible only through this class or by a derived class

 

Q15 What are different types of arguments ?

ANS : A parameter is a variable used during the declaration of the function or subroutine and arguments are passed to the function and it should match with the parameter defined there are two types of arguments called by value value passed will get modified only inside the function and it returns the same value whatever it is passed it into the function call by reference value passed will get modified in both inside and outside the functions and it returns the same or different value

 

Q16. What is super keyword ?

ANS : Super keyword is used to invoke overridden method which overrides one of its superclass methods this keyword allows to access overridden methods and also to access hidden members of the superclass it also forwards a call from a constructor to a constructor in the superclass

 

Q17. What is method overriding ?

ANS : Method overriding is a feature that allows subclass to provide implementation of a method that is already defined in the main class this will overrides the implementation in the superclass by providing the same method name same parameter and same return type - what is an interface an interface is a collection of abstract method if the class implements an inheritance and then thereby inherits all the abstract methods of an interface

 

Q18. What is exception handling ?

ANS : Exception is an event that occurs during the execution of a program exceptions can be of any type runtime exception error exceptions those exceptions are handled properly through exception handling mechanism like try catch and throw keywords 


Q19. What are tokens ?

ANS : Token is recognized by a compiler and it cannot be broken down into component elements keywords identifiers constants string literals and operators are examples of tokens even punctuation characters are also considered as tokens brackets commas braces and parentheses

 

Q20. Difference between overloading and overriding ?

ANS : Overloading is static binding whereas overriding is dynamic binding overloading is nothing but the same method with different arguments and it may or may not return the same value in the same class itself overriding is the same method names with same arguments and return types associates with the class and its child class

 

Q21. Difference between class and an object ?

ANS : An object is an instance of a class objects hold any information but classes don't have any information definition of properties and functions can be done at class and can be used by the object class can have subclasses and an object doesn't have sub objects

 

Q22. What is an abstraction ?

ANS : Abstraction is a good feature of hoops and it shows only the necessary details to the client of an object means it shows only necessary details for an object not the inner details of an object example when you want to switch on television it not necessary to show all the functions of TV whatever is required to switch on TV 


Q23. What are access modifiers ?

ANS : Access modifiers determine the scope of the method or variables that can be accessed from other various objects or classes there are five types of access modifiers and they are as follows private protected public friend protected friend

 

Q24. What is sealed modifiers ?

ANS : Sealed modifiers are the access modifiers where it cannot be inherited by the methods sealed modifiers can also be applied to properties events and methods this modifier cannot be applied to static members thirty how can we call the base method without creating an instance yes it is possible to call the base method without creating an instance and that method should be static method doing inheritance from that class you space key word from derived class

 

Q25.  What is the difference between new and override ?

ANS : The new modifier instructs the compiler to use the new implementation instead of the base class function whereas override modifier helps to override the base class function - what are the various types of constructors there are three various types of constructors and they are as follows default constructor with no parameters parametric constructor with parameters create a new instance of a class and also passing arguments simultaneously copy constructor which creates a new object as a copy of an existing object 


Q26. What is early and late binding ?

ANS : Early binding refers to assignment of values to variables during design time whereas late binding refers to assignment of values to variables during runtime thirty-four what is this pointer this pointer refers to the current object of a class this keyword is used as a pointer which differentiates between the current object with the global object 

 

Q27. What is the difference between structure and a class ?

ANS : Structure default access type is public but class access type is private a structure is used for grouping data whereas class can be used for grouping data and methods structures are exclusively used for data and it doesn't require strict validation but classes are used to encapsulate inherit data which requires strict validation

 

Q28. What is the default access modifier ?

ANS : In a class the default access modifier of a class is private by default share in your social networks and messengers

 

Q29. What is pure virtual function ?

ANS : A pure virtual function is a function which can be overridden in the derived class but cannot be defined a virtual function can be declared as pure by using the operator equals zero

 

Q30 What is dynamic or runtime polymorphism ?

ANS : Dynamic or runtime polymorphism is also known as method overriding in which call to an overridden function is resolved during runtime not at the compile time it means having two or more methods with the same name same signature but with different implementation 


Dinesh Wadhwani

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

1 comments:

  1. Top 30 Oops Interview Questions And Answers >>>>> Download Now

    >>>>> Download Full

    Top 30 Oops Interview Questions And Answers >>>>> Download LINK

    >>>>> Download Now

    Top 30 Oops Interview Questions And Answers >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete