Control statements in java : It is a statement that determines whether the other statements will be executed or not. It controls the flow of a program. control statements help with the control flow of the program. Control flow is the order in which the statements execute. Control Statements can be divided into three categories, namely A] Selection statement B] Iteration statement C] Jump statement Let us discuss above statements one by one as follow: A ] Decision-Making /Conditional /Selection statements: Statements that determine which statement to execute and when are known as decision-making statements. The flow of the execution of the program is controlled by the control flow statement. Selection statements allow your program to choose different paths of execution based upon the outcome of an expression or the state of a variable. Java supports two selection statements: I ] if statement: II ] switch statement: I] If st...
Java Applet : Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Applets are basically small java programs which can be transported from one computer from another computer in the network. Life cycle of Java Applet : Or Explain the life cycle of an applet with example? Or Describe different stage of life cycle of an applet? Applet is initialized. (Initial state) Applet is started.(running state) Applet is painted.(Display state) Applet is stopped.(idle or stoped state) Applet is destroyed.(dead state) When an applet is executed within the web browser or in an applet window, it goes through the four stages of its life cycle: initialized, started, stopped and destroyed.These stages correspond to the applet methods init(), start(), stop() and destroy() respectively. -->All above mention methods are defined in java.applet.Applet class except paint...
Interface : The interface is a blueprint that can be used to implement a class. It is similar to class. It is a collection of only abstract methods and static constants. Any service requirement specification is called as interface. Interface is an abstract type used to specify the behavior of a class. -The interface does not contain any concrete methods (methods that have code). -interface cannot contain instance fields(variables). -interface cannot be instantiated. -An interface cannot contains constructors or destructors. Advantages of interfaces : -Interfaces are used to achieve abstraction. -Interfaces are used to achieve multiple inheritance -Interfaces are used to achieve loose coupling. Defining an Interface : An interface is defined much like a class. The interface keyword is used to declare an interface. Syntax : access interface name { return-type method-name1(parameter-list); return-type method-name2(parameter...
Comments
Post a Comment