Cyber Infrastructure
Interview Questions and Answers
Q1. What is class what is object what is different between private protected and public and default
A class is a blueprint for creating objects, while an object is an instance of a class. Private, protected, public, and default are access modifiers in object-oriented programming.
A class is a template or blueprint that defines the properties and behaviors of objects.
An object is an instance of a class, created using the class blueprint.
Private access modifier restricts access to class members within the same class.
Protected access modifier allows access within the same class...read more
Q2. What is object ?
An object is a self-contained entity that consists of both data and behavior.
Objects are instances of classes in object-oriented programming.
They encapsulate data and provide methods to manipulate that data.
Objects can interact with each other through method calls and message passing.
Examples of objects include a car, a person, or a bank account.
Q3. What is public?
Public is a keyword in programming languages that denotes the accessibility of a class, method, or variable.
Public is one of the access modifiers in object-oriented programming.
It allows the class, method, or variable to be accessed from any other class or package.
Public members are part of the public API of a software component.
Example: public class MyClass { ... }
Example: public void myMethod() { ... }
Example: public int myVariable = 10;
Q4. What is private?
In programming, private is an access modifier that restricts the visibility of a class member to within its own class.
Private is used to encapsulate data and prevent direct access from outside the class.
Private members can only be accessed through public methods or properties.
Private variables are often used to store internal state or implementation details.
Private methods are used for internal logic and are not meant to be called from outside the class.
Q5. What is protected
protected is an access modifier in object-oriented programming that restricts access to members within the same package or subclasses.
protected is one of the four access modifiers in Java, along with public, private, and default.
Members declared as protected can be accessed within the same package or by subclasses.
Protected members are not accessible outside the package unless accessed through inheritance.
Example: protected int age; can be accessed by any subclass of the clas...read more
Q6. Difference between == and ===
The == operator checks for equality, while the === operator checks for strict equality (including data type).
The == operator only checks for equality of values, not data types.
The === operator checks for both equality of values and data types.
Example: 5 == '5' would return true, but 5 === '5' would return false.
Interview Process at null
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month