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 : " );      ...

Q) Retrieving data from database?

A)   ->to retrieve the data from database we need to submit SELECT statement from JDBC application. -> executeQuery() method of statement object is used for this purpose. This method has the fallowing ResultSet executeQuery(String sql) throws SQLException Ex: ResultSet rs = st.executeQuery(“SELECT * FROM ACCOUNT”); ->objectoriented representation of tables formate data is called ResultSet object. Ao the driver created one object i.e. ResultSet object. ->object orientation representation of a table of records returned from db is nothing but “ ResultSet ” object.  

Q) What is the purpose of JDBC?

A) -> Java application can do any task by making a method (function) call. ->java method calls are not understandable to database management system. They can understand only SQL statements. ->SQL statements can’t be directly used in a java application. Java compiler complains. ->therefore, we say that java environment and database environment are heterogeneous to each other. Purpose of JDBC: ->for any kind of java application to communicate with any kind of database (management system) in a standard manner, JDBC is used.