KnowledgeBoat Logo

Computer Applications

What is sequential flow of control? Explain with an example.

Java Conditional Stmts

14 Likes

Answer

In sequential flow of control, the statements of a program are executed from top to bottom in order in which they are written including method calls. During execution, the control is transferred to the method called. The method is then executed in a sequential order and upon its completion, the control is transferred back to the calling method and execution of statements continues sequentially. For example, the following program will be executed in a sequential manner:


public class SequentialExample {
    static void showGreeting() {
        System.out.println("Welcome to KnowledgeBoat");
    }

    public static void main(String args[]) {
        System.out.println("Sequential Execution Program Example");
        showGreeting();
    }
}

Answered By

9 Likes


Related Questions