Sathaya Institute Kvr Sir Java Notes in bedsramlofosse.gq for more Sathaya Institute Kvr Sir Java Notes to download in pdf format. Note: These notes are may be helpful for you but better to Attend K V Rao Sir K V Rao Core Java pdf1 Core Java Notes PDF1; K V Rao Core Java Pdf file 2. bedsramlofosse.gq Core Java notes - Free download as PDF File .pdf), Text File .txt) or read online for Download as PDF, TXT or read online from Scribd By Mr. K.V.R.
|Language:||English, Indonesian, Arabic|
|ePub File Size:||18.38 MB|
|PDF File Size:||15.44 MB|
|Distribution:||Free* [*Register to download]|
Kvr Advanced Java Notes,Advanced Java by Nataraj,Core Java By Kv KVR/ bedsramlofosse.gq Advanced Java Notes PDF -Ameerpet Materials. Core Java Notes By KV Rao/KVR PDF -Ameerpet Materials. Posted by SmlCodes. Core Java Notes By KV Rao(KVR)PDF -Ameerpet Materials. He will make you to understand the subject(JAVA) even if u dnt know any programing KV Rao Sir Advance Java Notes (Download PDF). kvr-advpdf.
A parameterized constructor is one which takes some parameters. Whenever we create an object using parameterized constructor, it is mandatory for the JAVA programmer to define parameterized constructor otherwise we will get compile time error. Overloaded constructor is one in which constructor name is similar but its signature is different. Signature represents number of parameters, type of parameters and order of parameters.
Here, at least one thing must be differentiated. When we define a class, that class can contain two categories of constructors they are single default constructor and n number of parameterized constructors overloaded constructors.
Write a JAVA program which illustrates the concept of default constructor, parameterized constructor and overloaded constructor? By default the parameter passing mechanism is call by reference. They are i. Whenever the formal parameters and data members of the class are similar, to differentiate the data members of the class from formal parameters, the data members of class must be proceeded by this. Rule for this: Whenever we use either this or this in the current class constructors, that statements must be used as first statement only.
The order of the output containing this or this For more clarity refer the above program. For example we need output as follows: We must write in the following order as input: Test 10 ; Test , ; Whenever we refer the data members which are similar to formal parameters, the JVM gives first preference to formal parameters whereas whenever we write a keyword this before the variable name of a class then the JVM refers to data members of the class.
If any method called by an object then that object is known as source object. If we pass an object as a parameter to the method then that object is known as target object.
In the definition of display method t1 data members are referred by this. Data member names this. Data member names T.
K.V.rao Core Java notes
Write a JAVA program which computes sum of two objects by accepting the data from command prompt? They are is-a relationship, has-a relationship and uses-a relationship. Is-a relationship is one in which data members of one class is obtained into another class through the concept of inheritance. Has-a relationship is one in which an object of one class is created as a data member in another class.
Uses-a relationship is one in which a method of one class is using an object of another class. Inheritance is the technique which allows us to inherit the data members and methods from base class to derived class.
Base class is one which always gives its features to derived classes. Derived class is one which always takes features from base class. A Derived class is one which contains some of features of its own plus some of the data members from base class. Here, clsname-1 and clsname-2 represents derived class and base class respectively. Extends is a keyword which is used for inheriting the data members and methods from base class to the derived class and it also improves functionality of derived class.
Final classes cannot be inherited. If the base class contains private data members then that type of data members will not be inherited into derived class. Whenever we develop any inheritance application, it is always recommended to create an object of bottom most derived class. Since, bottom most derived class contains all the features from its super classes. One class can extend only one class at a time. Since, JAVA does not support multiple inheritance.
Whenever we inherit the base class members into derived class, when we creates an object of derived class, JVM always creates the memory space for base class members first and later memory space will be created for derived class members. Whatever the data members are coming from base class to the derived class, the base class members are logically declared in derived class, the base class methods are logically defined in derived class.
Private data members and private methods of the base class will not be inherited at all. Write a JAVA program computes sum of two numbers using inheritance? For every class in JAVA we have a super class called object class. The purpose of object class is that it provides garbage collector for collecting unreferenced memory locations from the derived classes.
Super keyword: Super keyword is used for differentiating the base class features with derived class features. Super keyword is placing an important role in three places. They are at variable level, at method level and at constructor level. Super at variable level Whenever we inherit the base class members into derived class, there is a possibility that base class members are similar to derived class members. In order to distinguish the base class members with derived class members in the derived class, the base class members will be preceded by a keyword super.
Super at method level Whenever we inherit the base class methods into the derived class, there is a possibility that base class methods are similar to derived methods. To differentiate the base class methods with derived class methods in the derived class, the base class methods must be preceded by a keyword super.
Syntax for super at method level: Super at constructor level Whenever we develop any inheritance application, we use to create always object of bottom most derived class. When we create an object of bottom most derived class, it in turns calls its immediate super class default constructor and it in turns calls its top most super class default constructor.
Therefore, in JAVA environment, constructors will be called always from bottom to top and the execution starts from top to bottom. Consider the following multi level inheritance:. Super is used for calling super class default constructor from default constructor or from parameterized constructor of derived class. It is optional. Super is used for calling super class parameterized constructor either from default constructor or from parameterized arameterized constructor of derived class.
It is always mandatory. Whenever we use either super or super in derived class constructors they must be used as first statement. Whenever we want to call default constructor of base class from default constructor of derived class using super in default constructor of derived class is optional. Whenever we want to call the super class parameterized class from parameterized class of the derived class using super in parameterized class of derived class is mandatory.
Whenever we want to call default constructor of base class from parameterized class of derived class using super in parameterized class of derived class is optional. Whenever we want to call parameterized class of base class from default constructor of derived class using super in default constructor of derived class is mandatory.
Best example for the above given rules: In JAVA we have two types of classes. They are concrete classes and abstract classes.
A concrete class is one which contains fully defined methods. Defined methods are also known as implemented or concrete methods. With respect to concrete class, we can create an object of that class directly. An abstract class is one which contains some defined methods and some undefined methods. Undefined methods are also known as unimplemented or abstract methods.
Abstract method is one which does not contain any definition. To make the method as abstract we have to use a keyword called abstract before the function declaration. The abstract methods make us to understand what a method can do but it does not give how the method can be implemented. Every abstract method belongs to a class under class is known as abstract class, to make the class as abstract we use a keyword called abstract before the class specification.
With respect to abstract class we cannot create an object direct but we can create indirectly. An object abstract class is equal to an object of that class which extends that abstract class.
KVR JAVA Notes-2.pdf - J2EE(core JAVA Notes Day 27...
Write a JAVA program for computing sum of two integers and floats using abstract classes? Abstract classes should not be final, since, they are always reusable. Abstract classes are basically used to implement polymorphism; we use the concept of dynamic binding. Hence, abstract classes, polymorphism and dynamic binding will improve the performance of JAVA J2EE applications by reducing amount of memory space.
Whenever we inherit n number of abstract methods from abstract base class to derived class, if the derived class defines all n number of abstract methods then the derived class is concrete class. If the derived class is not defining at least one abstract method out of n abstract methods then the derived class is known as abstract derived class and to make that class abstract, we use a keyword called abstract.
An abstract base class is one which contains physical representation of abstract methods. An abstract derived class is one which contains logical declaration of abstract methods which are inherited from abstract base class.
Implement the above diagram by using abstract classs polymorphism and dynamic binding. With respect to Concrete Class: An object of either concrete base class or abstract base class contains the details about those methods which are available in that class only but this object concrete base class or abstract base class does not contains details of those methods which are specially defined in derived classs. Write a JAVA program to display the fonts of the system?
A factory method is one whose return type is similar to name of the class where it presents. RULES for factory method: The return type of the factory method must be similar to name of the class where it presents. Every factory method must be static so that we can call with respect to name of the class.
Every factory method must be public. Factory methods are used for creating an object without using new operator. Every predefined abstract class contains at least one factory method for creating an object of abstract class. Whenever we define a concrete class, that concrete class also can be made it as abstract and it is always further reusable or extendable by further classes.
When we define only concrete class we may extend or we may not extend by derived classes. Interfaces are basically used to develop user defined data types. With respect to interfaces we can achieve the concept of multiple inheritances.
With interfaces we can achieve the concept of polymorphism, dynamic binding and hence we can improve the performance of a JAVA program in turns of memory space and execution time. An interface is a construct which contains the collection of purely undefined methods or an interface is a collection of purely abstract methods.
Syntax for defining an interface: Interface is a keyword which is used for developing user defined data types. Interface name represent a JAVA valid variable name and it is treated as name of the interface.
With respect to interface we cannot create an object directly but we can create indirectly. Variable declaration represents the type of data members which we use a part of interface. Whatever the variables we use in the interface are meant for general purpose the variables like PI, e, etc. Whatever the variables we write in the interface, they are by default belongs to: All variables must be initialized otherwise it will be compilation error.
Method declaration represents the type of methods we use as a part of interface. All the methods of interface are undefined methods and to make those methods as abstract, the JAVA programmer need not to write a keyword abstract explicitly before the declaration of interface method.
Since all the methods of interface are meant for general purpose hence they must give universal access. To make it as universal access the JAVA programmer need not to write a keyword public explicitly before the method declaration.
Hence, by default all the methods of interfaces belong to public abstract methods. Syntax-1 for reusing the features of interface s to class: In the above syntax clsname represents name of the class which is inheriting the features from n number of interfaces.
Implements is a keyword which is used to inherit the features of interface s to a derived class. When we inherit n number of abstract methods from n number of interfaces to the derived class, if the derived class provides definition for all n number of abstract methods then the derived class is known as concrete class. If the derived class is not providing definition for at least one abstract class and it must be made as abstract by using a keyword abstract.
One class can extend only one class. One class can implement n number of interfaces. One interface can extends more than one interface. Interface cannot implements or extends a class.
Since defined things cannot be made as undefined things. Syntax-2 inheriting n number of interfaces to another interface: If one interface is taking the features of another interface then that inheritance is known as interface inheritance Syntax Whenever we use both extends and implements keywords as a part of JAVA program we must always write extends keyword first and latter we must use implements keyword.
Important points: An object of interface cannot be created directly since it contains n number of abstract methods. An object of interface can be created indirectly.
An object of base interface contains the details about those methods which are declared in that interface only but it does not contain details about those methods which are specially available in either in derived classes or in derived interfaces. Interfaces should not be final. An interface does not contain Constructors. A sub-package in turns divides into classes, interfaces, sub-sub-packages, etc.
Learning about JAVA is nothing but learning about various packages. By default one predefined package is imported for each and every JAVA program and whose name is java. Whenever we develop any java program, it may contain many number of user defined classes and user defined interfaces. In java we have two types of packages they are predefined or built-in or core packages and user or secondary or custom defined packages.
Core packages of java starts with java. As a part of J2SE we have nine predefined packages which are given in the following table: Package name java. This is the package which is by default imported for each and every java program.
This package is used for developing file handling applications, such as, opening the file in read or write mode, reading or writing the data, etc.
This package is used for developing GUI Graphic Unit Interface components such as buttons, check boxes, scroll boxes, etc. Event is the sub package of awt package. This package is used for providing the functionality to GUI components, such as, when button is clicked or when check box is checked, when scroll box is adjusted either vertically or horizontally.
This package is used for developing browser oriented applications. In other words this package is used for developing distributed programs. An applet is a java program which runs in the context of www or browser. This package is used for developing client server applications. This package is used for developing quality or reliable applications in java or J2EE. This package contains various classes and interfaces which improves the performance of J2ME applications.
This package is also known as collection framework collection framework is the standardized mechanism of grouping of similar or different type of objects into single object.
This single object is known as collection object. This package is used for formatting date and time on day to day business operations. Reflect is the sub package of lang package.
This package is basically used to study runtime information about the class or interface. Runtime information represents data members of the class or interface, Constructors of the class, types of methods of the class or interface.
This package is used for retrieving the data from data base and performing various operations on data base. Any class or interface is commonly used by many java programmers that class or interface must be placed in packages. Here, package is a keyword which is used for creating user defined packages, pack1 represents upper package and pack2 to packn represents sub packages. The statements 1 and 2 are called package statements. Whenever we create user defined package statement as a part of java program, we must use package statement as a first executable statement.
Whenever we develop any JAVA program it contains n number of classes and interfaces. Each and every class and interface which are developed by the programmer must belong to a. Choose the appropriate package name, the package name must be a JAVA valid variable name and we showed ensure the package statement must be first executable statement. Choose the appropriate class name or interface name and whose modifier must be public. The modifier of Constructors of a class must be public.
The modifier of the methods of class name or interface name must be public. At any point of time we should place either a class or an interface in a package and give the file name as class name or interface name with extension.
Here, -d is an option or switch which gives an indication to JVM saying that go to Test. When Test. The above program cannot be executed since it doesnt contain any main method. In order to refer package classes and interfaces in JAVA we have two approaches, they are using import statement and using fully qualified name approach. Using import statement: Import is a keyword which is used to import either single class or interface or set of classes and interfaces all at once.
When statement 1 is executing we can import or we can access all the classes and interfaces of package p1 only but not its sub packages p2 and p3 classes and interfaces. When statement 2 is executing we can import as the classes and interfaces of package p2 only but not p1 and p3 classes and interfaces.
When statement 3 is executing we can import as the classes and interfaces of package p3 only but not p1 and p2 classes and interfaces. Import pack1 [. When statement 4 is executing can import c1 class of package p1 only but not other classes and interfaces of p1 package, p2 package and p3 package.
Write a JAVA program which illustrates the usage of package classes?
Import approach: When we compile the above program we get the following error package tp does not exist. To avoid the above error we must set the classpath as. Fully qualified approach: Test ; t1. Whenever we develop user defined packages, to use the classes and interfaces of user defined packages in some other program, we must set classpath before there usage.
In order to set the classpath for predefined packages we must use the following statement: When two classes or an interface belongs to the same package and if they want to refer those classes or interfaces need not to be referred by its package name. C02" ; cp. C02 ; o2.
C01" ; cp. C02 ; o1. C02 ; io. In order to run the above program we must run with respect to package name. In JAVA we have four types of access specifiers.
They are private, default not a keyword , protected and public. Access specifiers makes us to understand how to access the data within the package class to class, interface to interface and interfaces to class and across the package class to class, interface to interface and interfaces to class.
In other words access specifiers represent the visibility of data or accessibility of data. Syntax for declaring a variable along with access specifiers: Private Same package base class Same package derived class Same package independent class Other package derived class Other package independent class.
Private access specifier is also known as native access specifier. Default access specifier is also known as package access specifier. Protected access specifier is also known as inherited access specifier. Public access specifier is also known as universal access specifier. Write a JAVA program which illustrates the concept of access rules? Sbc; import sp. Sdc; import sp. Odc ; System. Nameless object approach: Sometimes there is no necessity for the JAVA programmer to create an object with some name.
In such situations we can use the concept of nameless object. To convert the above statements into nameless object approach follow the following statements.
Every technology or every programming language, if we use for implementing real time applications and if the end user commits a mistake then by default that language or technology displays system error messages which are nothing but run time errors.
Run time errors in JAVA are known as exceptions. System error messages are those which are unable to understand by end user or client. User friendly messages are those which are understandable by end user or client. Exceptional handling is a mechanism of converting system error messages into user friendly messages.
Errors are of two types. They are compile time errors and run time errors. Compile time errors are those which are occurring because of poor understanding of the language. Run time errors are those which are occurring in a program when the user inputs invalid data. The run time errors must be always converted by the JAVA programmer into user friendly messages by using the concept of exceptional handling. In JAVA run time environment, to perform any kind of operation or task or an action that will be performed with respect to either class or an interface.
Whenever we pass invalid data as an input to t the he JAVA program then JAVA run time environment displays an error message, that error message is treated as a class. Types of exceptions: In JAVA we have two types of exceptions they are predefined exceptions and user or custom defined exceptions. Predefined ned exceptions are those which are developed by SUN micro system and supplied as a part of JDK to deal with universal problems. Some of the universal problems are dividing by zero, invalid format of the number, invalid bounce of the array, etc.
Predefined exceptions are divided into two types. They are asynchronous exceptions and synchronous exceptions. Asynchronous exceptions are those which are always deals with hardware problems. In order to deal with asynchronous exceptions there is a predefined class called java.
Error class is the super class for all asynchronous exceptions. Synchronous exceptions are one which always deals with programmatic errors. In order to deal with synchronous exceptions we must use a pred predefined class called java. Exception class. Exception is the super class for all synchronous exceptions. Synchronous exceptions are divided into two types.
They are checked exceptions and unchecked exceptions. A checked exception is one which always deals with compile time errors regarding class not found and interface not found.
An exception is an object which occurs at run time which describes the nature of the message. The nature of the message can be either system error message or user friendly message. JRE contacts to java. Throwable for finding what type of exception it is. Throwable decides what type of exception it is and pass the message to JRE.
Error class or java. Exception class will fo found an appropriate sub class exception. Either java. Exception class gives an appropriate exception class to JRE. JVM will create an object of appropriate exception class whi which ch is obtained from JRE and it generates system error message. In order to make the program very strong robust , JAVA programmer must convert the system error messages into user friendly messages by using the concept of exceptional handling.
User friendly y messages are understand by normal user effectively hence our program is robust. Syntax for exceptional handling: In order to handle he exceptions exceptions in JAVA we must use the following keywords.
They are try, catch, finally, throws and throw. Try block: This is the block in which we write the block of statements which are to be monitored by JVM at run time i.
If any y exception is taking place the control will be jumped automatically to appropriate catch block. If any exception is taking place in try block execution will be terminated and the rest of the statements in try block will not be executed at all and the control control will go to catch block.
For every try block we must have at least one catch block. It is highly recommended to write n number of catchs for n number of problematic statements. Catch block: This is used for providing user friendly messages by catching system error messages. In the catch we must declare an object of the appropriate execution class and it will be internally referenced JVM whenever the appropriate situation taking place.
If we write n number of catchs as a part of JAVA program then only one catch will be executing at any point. After executing appropriate catch block even if we use return statement in the catch block the control never goes to try block. Finally block: This is the block which is executing compulsory whether the exception is taking place or not.
This block contains same statements which releases the resources which are obtained in try block resources are opening files, opening databases, etc. Writing the finally block is optional.
Throws block: This is the keyword which gives an indication to the calling function to keep the called function under try and catch blocks. Write a JAVA program which illustrates the concept of throws keyword?
Number of ways to find details of the exception: In JAVA there are three ways to find the details of the exception. They are using an object of java. Exception class, using public void printStackTrace method and using public string getMessage method.
KVR JAVA Notes-2.pdf - J2EE(core JAVA Notes Day 27...
Using an object of java. An object of Exception class prints the name of the exception and nature of the message. Using printStackTrace method: This is the method which is defined in java. Throwable class and it is inherited into java. Error class and java. This method will display name of the exception, nature of the message and line number where the exception has taken place. Using getMessage method: This is also a method which is defined in java. Throwable class and it is inherited into both Error and Exception classes.
This method will display only nature of the message. Guide lines for developing user defined exceptions: Choose the appropriate package name. Choose the appropriate user defined class. Every user defined class which we have choose in step 2 must extends either java. Exception or java. RunTimeException class. Every user defined sub-class Exception must contain a parameterized Constructor by taking string as a parameter.
Every user defined sub-class exception parameterized Constructor must called parameterized Constructor of either java. RunTimeException class by using super string parameter always.
Write a JAVA program which illustrates the concept of user defined exceptions? Nage; import ap. Age ; Ao. Main method should not throw any exception since the main method is called by JVM and JVM cannot provide user friendly message. They are standalone applications and distributed applications. A standalone application is one which runs in the context of local disk and whose result is not sharable.
Every standalone application runs from command prompt and it contains main method along with System. A distributed application is one which runs in the context of browser or World Wide Web and it can be accessed across the globe. Any technology which runs in the browser will have n number of life cycle methods and it does not contain main methods and System. In order to deal with applets we must import a package called java. This package contains only one class Applet whose fully qualified name is java.
Since applets are running in the browser, the class Applet contains the life cycle methods. Life cycle methods are also called as loop back methods. In java. Applet we have four life cycle methods. They are public void init , public void start , public void stop and public void destroy.
Public void init: This is the method which is called by the browser only one time after loading the applet. In this method we write some block of statements which will perform one time operations, such as, obtaining the resources like opening the files, obtaining the database connection, initializing the parameters, etc.
Public void start: After calling the init method, the next method which is from second request to sub-sequent requests the start method only will be called i. In this method we write the block of statement which provides business logic.
Public void stop: This id the method which is called by the browser when we minimize the window. In this method we write the block of statements which will temporarily releases the resources which are obtained in init method. Public void destroy: This is the method which will be called by the browser when we close the window button or when we terminate the applet application. In this method we write same block of statements which will releases the resources permanently which are obtained in init method.
Another method which is not a life cycle method is public void paint. This is the method which will be called by the browser after completion of start method. This method is used for displaying the data on to the browser. Paint method is internally calling the method called drawString whose prototype is given below. An object of Graphics class will be created automatically after loading the applet into the browser. Import java.
Applet package. Choose the user defined class that must extends java. Applet class and ensure the modifier of the class must be public. Overwrite the life cycle methods of the applet if require. Save the program and compile. Run the applet: To run the applet we have two ways.
>> SUNDAY, FEBRUARY 9, 2014
They are using HTML program and using applet viewer tool. Using HTML program: In order to run the applet through HTML program we must use the following tag.
File name: Using appletviewer: Appletviewer is a tool supplied by SUN micro system to run the applet programs from the command prompt in the case of browser is not supporting.
When we use appletviewer to run the above applet, MyApp. Write an applet program which displays AshaKrishna My Love? Applet; public class MyApp extends Applet. To set the font we must use a class called Font.
Graphics public void setFont Font fobj. Write a JAVA program which illustrates the life cycle methods of applet? BOLD, 40 ; g. A standalone GUI application is one which runs in the context of local disk and our class must extends a predefined class called java. Frame class. A distributed GUI application is one wh which ich runs in the context of browser and our class must extend java. Applet class. As a part of GUI applications we use to create two types of components.
They are passive components and active components. A passive component is one where there is no interaction from the user. For example label. An active component is one where there is an interaction from the user. For example button, check box, scroll bar, etc. The active and passive components in JAVA are available in terms of classes. In order to deal with any GUI applications we must import a package called java. Whenever we develop any GUI application we must have readily available window component and window component must contain frame component.
Any GUI component which we want to create gives the corresponding class and adds all those components to the object of Container class. A Container is a class whose object allows us to add n number of similar or different GUI components to make a final application. Except Object class and Applet class all the classes in the a above bove hierarchy chart are belongs to java. The methods in line numbers 1 and 2 defined in java. Window class. The methods in line numbers 3, 4 and 5 are defined in java.
Component class. Label class: Label is a class which is used for creating label as a part of windows application. The component label comes under passive component. Labels always improve the functionali functionality and readability of active components.
Creating a label is nothing but creating an object of label components. Label class API: Data members: The above three statements are called alignment parameters or modifiers. Label Label String Label String label name, int alignment modifier. Instance methods: For example we can write a program as follows: RIGHT ;. Event Delegation Model: Whenever we want to develop any windows applications one must deal with event delegation model.
Event delegation model contains four properties. In order to process any active components, we must know either name or caption or label or reference of the component object. Whenever we interact any active component, the corresponding active component will have one predefined Event class, whose object will be created and that object contains two details: Name of the component.
Reference of the component. The general form of every Event class is xxx event. Component name print choice textField textArea scrollbar.
Event name java. ActionEvent java. ItemEvent java. TextEvent java. In order to perform any action or operation when an interactive component is interacted we must write some set of statements into the appropriate methods. These methods are not defined or. In JAVA purely undefined methods are abstract methods present in interfaces. Interfaces in awt are called listeners.
Hence, every interactive component must have a predefined listener whose general notation is xxx listener. Listener name java. ActionListener java. ItemListener java. TextListener java. Identity what is the undefined method or abstract method in xxx Listener. Undefined method name public public public public void void void void actionPerformed actionPerformed actionPerformed actionPerformed java.
Each and every interactive component must be registered and unregistered with particular event and Listener.
The general form of registration and un-registration methods is as follows: Button is an active component which is used to perform some operations such as saving the details into the database, deleting the details from the database, etc. Creating a button is nothing but creating an object of Button class.
Button API: Button ; Button String ;. Write a java program to illustrate the concept of buttons? Steps for developing awt program: Import the appropriate packages. Choose the appropriate class and it must extend java. Frame and implements appropriate Listener if required.
Identify which components we want and declare them as data members in the class. Set the title for the window. Set the size of the window. Create the components which are identified in step 3. Add the created components to container. Register the events of the appropriate interactive component with appropriate Listener. Make the components to be visible. Define the undefined methods in the current class which is coming from appropriate Listener. This method provides functionality to GUI component.
Rewrite the above program using applets? Applet; import java. Import appropriate packages for GUI components java. Every user defined class must extend either Frame or Applet and it must implement appropriate Listener if required. Identify which components are required to develop a GUI application. Use life cycle methods init, start, destroy in the case of applet, use default Constructor in the case of Frame for creating the components, adding the components, registering the components, etc.
Set the title of the window. Set the layout if required. Create those components which are identified. Every interactive component must be registered with appropriate Listener. Make the components to be visible in the case of Frame only.
Implement or define the abstract method which is coming from appropriate Listener. Choice is the GUI component which allows us to add n number of items. This component allows selecting a single item at a time. Creating a choice component is nothing but creating an object of Choice class. Choice API: Methods 1 and 2 are used for adding items to the choice component at end.
Methods 3 and 4 are used for adding the items at the specified position. Page Methods 5 and 6 are used for obtaining the items either based on its name or on its index. Methods 7 and 8 are used for removing the item of the choice component either based on its name or on its index position. Method 9 is used for removing all the items of choice components.
Methods 10 and 11 are used for registering and unregistering the events of choice components. Write a java program which illustrates the concept of Choice? Checkbox is basically used for maintaining checklist purpose checkbox is an interactive component which contains a square symbol and a label.
Creating a checkbox is nothing but creating an object of checkbox class By Mr. Checkbox API: Write a java program which illustrates the concept of Checkbox? Steps for converting checkboxes into radio button: Create objects of CheckboxGroup class. CheckboxGroup object allows to select a single checkbox among n number of checkboxes.
Create n number of objects of Checkbox class. Decide which checkboxes are adding to which CheckboxGroup object. In order to add the checkboxes to the CheckboxGroup object, in Checkbox class we have the following method: Register the events of checkbox with ItemListener by using the following method: Instead of using a setCheckboxGroup method we can also used the following Constructor which is present in Checkbox class.
Write a java program which illustrates the concept of Radio Button? TextField is GUI interactive component which allows entering the data in single line. Whatever the data, we enter to text field, by default that data will be treated as string. If we are able to read the data of text field then that text field is known as editable or nonecho or normal text field.
If we are unable to read the data of the text field then that text field is known as echo text field and the character which is available is known as echo character. Creating a text box is nothing but creating an object of TextField class. TextField API: Write a java program which illustrates the concept of TextField? Write a java program to close the window of awt?
Adapter class: It is one which contains null body definition for those methods which are inheriting from appropriate Listener. In the derived class implements WindowListener interface; it is mandatory for derived class to define all the methods even though the derived class is not required. If the derived class wants to define the required methods, it has to extend its corresponding adapter class called java.
WindowAdapter and this class contains null body definition for WindowListener interface methods. Therefore which our Listener interface contains more than one undefined method for that Listener interfaces we have the appropriate adapter class whose general notation is XXXAdapter.
TextArea is the GUI interactive component in which we can enter multiple lines of information such as addresses, remarks, achievements, etc. Creating a TextArea is nothing but creating an object of TextArea class.
Whenever we create a TextArea component by default Scrollbars will be in invisible mode. Whenever number of rows are exceeding automatically we get vertical scrollbar whereas when number of columns are exceeding we get horizontal scrollbar.
TextArea API: TextArea ; TextArea int rows, int cols ; TextArea int rows, int cols, int scroll visibility modifier ;. Write a java program which illustrates the concept of TextArea? List is the GUI interactive component which allows to select either single or multiple items at a time. Creating List component is nothing but creating an object of List class. List API: List ; List int size ; List int size, boolean mode ;.
When we want to select the items of the list with single click then we must register with ItemListener to select items of the list with double click then we must register with ActionListener. Write a java program which illustrates the concept of List? Mouse operation: Portable: A portable language is one which can run on all operating systems and on all processors irrespective their architectures and providers.
Multi Threading: Day - 6: Definitions: 1. A flow of control is known as thread. A multi threaded program is one in which there exists multiple flow of controls i. A program is said to be multi threaded program if and only of there exists n number of subsub programs. For each and every sub-program sub there exists a separate flow of control.
All such flow of controls are executing concurrently. Such flow of controls is known as threads. Such type of applications is known kno as multi threading applications. SMTL are those in which there exists single flow of control. MTML are those in which there exist multiple flows of controls. Whenever we write a JAVA program there exists by default two threads. A foreground thread is one which always executes user defined sub-programs.
In a JAVA program there is a possibility of existing n number of foreground threads. A background thread is one which always monitors the status of foreground thread. In each and every JAVA program there t exists only one background thread.
Hence background thread will be created first and later foreground thread will be created. Distributed: A service is a said to be a distributed service which runs in multiple servers and that service can be accessed by n number of clients across the globe.
In order to develop distributed applications we must require architecture called trusted network architecture. To develop these applications we require a technology called J2EE. Distributed applications are preferred preferr by large scale organizations. Networked: In real world we have two types of networks. They are un-trusted trusted networks and trusted networks.
Un-trusted networks: A network is said to be un-trusted network in which there exists n number of inter connected non-autonomous autonomous architecture. Un-trusted network is also known as LAN. Using this network architecture, we develop centralized applications. A centralized application is one which runs on single server and it can be access in limited graces. In order to develop centralized applications we may use a technology called J2SE and these kinds of applications are preferred by small scale organization.
Trusted network: A network is said to be trusted network in which there exists n number of inter connected autonomous architecture. Trusted network is also known as WAN. Using this network, we can develop distributed applications.
A distributed application is one which runs on multiple servers and it can be access in unlimited graces. In order to develop distributed applications we may use By Mr. They are procedure oriented programming language and object oriented programming language.
If we represent the data using procedural oriented programming languages then there is no security for the data which we represent. If one of the functions manipulates or damages the data then we are loosing correction-less less integrity of the data. When we represent the data in object oriented programming language we get the security. In order to say any language is an object oriented programming language it has to satisfy 8 principles of OOPs.
OOPs Principles: 1. Data Abstraction. Data Encapsulation. Dynamic Binding. Message Passing. Any JAVA program if we want to develop then that should be developed with respective class only i. In object oriented programmings, generally we write two types of methods.
They are member methods and non-member member methods. A member method is one which is comes under the scope of the class. In JAVA we use only member methods. Non-member member methods are those which are not comes under the scope of the class. JAVA does not allow non-member member methods at all.
Clsname represents a JAVA valid variable name and it is treated as name of the class. Class names are used for creating objects. Class contains two parts namely variable declaration and method definitions. Variable declaration represents what type of data members which we use as a part of the class. Method definition represents the type of methods which we used as the path of the class to perform an operation.
By making use of the variables, variables which are declared inside the class? Every operation in JAVA must be defined with in the class only i. Memory space will be created for the data members of the class when we create object. NOTE: 1. Memory space for methods will be creating on stack memory that too when we call the methods.They are compile time errors and run time errors. They are is-a relationship, has-a relationship and uses-a relationship.
Super at method level Whenever we inherit the base class methods into the derived class, there is a possibility that base class methods are similar to derived methods. Each and every wrapper class contains the following generalized parse methods.
UNICODE character set is one which contains all the characters which are available in 18 international languages and it contains characters.