Skip to main content

Q) Explain about “class and object “?




A)
->combining data and eligible code that acts upon that data into one unit is known as encapsulation.
->in an application, programmatically, by defining a class we combine variables and methods as a unit. Therefore, we say class is the basis to implement encapsulation. But memory is not allocated unless we create an instance of the class. I.e. object.  Actual storage of data happens in the object. Methods act upon the object to process data stored in the object.
We say that object implements encapsulation. However, object can’t be created without class.
->theoretical object oriented feature called encapsulation is programmatically is achieved through class and object.
Additional:
Encapsulation is combining data and its eligible code in a unit.
Encapsulation is object oriented feature but class is not.
To achieve object oriented feature encapsulation achieve with class. Class is basis for organizing data and methods. So class is the basis to implement the encapsulation. Object is real implementation.-> -->A class is a user defined data type.
->a class is similar to a structure in c as far as organizing one entity’s related data into one unit is concerned.
->a class contains properties/variables and eligible methods that acts upon the data stored in those variables. Therefore, we say class is the basis of encapsulation.
->a class is a specification for the structure and behavior of the object.
->A class is a template/plan/proposal for the object.
->An object is an instance of a class.
->Physical realization of a class is nothing but an object.
->an object is a data storage area. Where one real world entity’s data is stored in secured manner.
->in an object oriented application, a fundamental unit of data storage is nothing but an object.
->An object has variables and associated methods.
->instance variable of a class contributed to the structure/size of the object but not the methods.
Even though methods belong to the object, they don’t contribute to the size of the object.
An object has 3 things.
1)      Identity
2)      State
3)      Behavior
->object implements the encapsulation, class is basis of the object.
Identity: name of the object with which, it is uniquely identified known as identity. In java, reference acts as the name of the object and hence reference is object’s identity.
State:
Instance of the class are nothing but properties of the object. Properties and current values they hold put together is nothing but state of the object. I.e. data stored in an object is known as state of the object. State in nothing but date. Not variable.
Behavior:
A method of the object is known as it behavior. An object’s state can be manipulated only by its behavior. This is the complete essence of object orientation. External behavior can influence the object behavior to change the object state. The functional part of the object is nothing but behavior.

Comments

Popular posts from this blog

Q) Explain repeated deletion of records.

A) //RepeatedDeletion.java import java.util.Scanner; import java.sql.*; class RepeatedDeletion {        public static void main(String[] args) {               Connection con= DriverManager. getConnection ( "jdbc:odbc:prince" , "scott" , "tiger" );               PreparedStatement ps=con.PreparedStatement( "DELETE FROM ACCOUNT WHERE ACCNO=?" );               Scanner s= new Scanner(System. in );               while ( true )               {                      System. out .println( "Enter accno : " );      ...

Introduction

1) What is not JDBC? 2) What is the purpose of JDBC? 3) What is ODBC? 4) What is JDBC? 5) What is JDBC architecture? 6) What is JDBC client? What are its responsibilities? 7) What is JDBC API?  8) What is driver manager? 9) What is JDBC driver? What is its role in java database connection? 10) What is database server?

Q) Explain about nested classes?

A) ->defining a class with in another class is known as nesting of the class. Ex: class A {        class B        {                      } //nested class, and inner class.because it is not static class. } //enclosing class or outer class. ->static class is declared in inside an another class then it does not become an inner class. Note: non-static nested class is known as “inner class”. In the above example class B is nested but not an inner class. Ex: class D {        static c        {                      } //nested class, but not an inner class , because of static class. } //outer class. ->we have three different kinds of inner classes. 1) Member inner class 2) Meth...