Skip to main content

Q) What is a package?


A)

->a package is a grouping mechanism which related class files are grouped and made available to other applications or other part of the same application.

->a package creates a namespace (logical container, we can’t have 2 files with same name).
->directory also holds files like package, but difference is ‘directory’ can’t be made available to either applications where as package can do it. Directory is a name given to the os files system terminology where as package is a java terminology.
->a package provides the fallowing
1) Some level of security in the application.
2) Provides namespace (logical container) when no 2 class files have the same name.
3) Grouping of related class files and there by easy maintenance
4) Making the class files available to other applications and other part of same allocation.
Note:
no class files exists in java which doesn’t belong to a package.
->available in missing with default package. I.e. The package where the class files store in a folder only.
Packages are 2 types
1) Pre defined (built-in) package (library class files)
2) User defined package

->in built in packages library class files are grouped.
->In user defined package applications, user defined class files are grouped.
->in java, we have 2 kinds of built in packages.
1) Core packages
2) Extension packages

Jar –xf rt.jaràun zipping g
Core packages



->for every application by default package is java.long package. It is implicitly available.
->library inclusion in c is static i.e. the header files contribute to the size of the program.
->library inclusion in java is dynamic i.e. all does not contribute to size of object. Only particular one contributes.
->indicates availability of class files in a package but sub package class files are not available.
->in a java application, if we use library class without import it then we get compilation error. if that class belongs to other than long package.
->we include util package into a java application as fallows

import java.util.*;

-> ’*’ indicates that it does not represent sub package class files of util package. The above syntax does not package into current java applications process space. It makes all the class files of util package available to java application? At run time which library class files of that package we use in the applications. Those class files only be loaded into memory. This is known as “library inclusion is dynamic in java”.
->in ‘c’ whether we use the library in the program or not. Entire is contributed to size of program. Whenever in java it is not like that only particular one is contributed to size of program.
 ->if we ‘import’ out of the class does not mean violation of encapsulation. Because we are not programming any data, we are making many encapsulated units available to the application.

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...