Keywords in Java Description: Java Programming Package Synchronized Blocks
The document defines keywords in Java and provides a brief description of each keyword. Some key keywords include abstract for abstract classes, continue to continue to the next iteration of a loop, for for looping, new to create objects, switch for conditional checking, assert for validating conditions, default for switch statements, package for grouping classes and interfaces, synchronized for thread synchronization, boolean for true/false values, do while for looping until a condition is met, if for conditional checking, private for restricting access, this for referring to the current object, break to exit loops, double for floating-point numbers, implements for implementing interfaces, protected for restricting access, throw for throwing exceptions, byte for 8-bit integer, else for alternative code blocks,
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
30 views
Keywords in Java Description: Java Programming Package Synchronized Blocks
The document defines keywords in Java and provides a brief description of each keyword. Some key keywords include abstract for abstract classes, continue to continue to the next iteration of a loop, for for looping, new to create objects, switch for conditional checking, assert for validating conditions, default for switch statements, package for grouping classes and interfaces, synchronized for thread synchronization, boolean for true/false values, do while for looping until a condition is met, if for conditional checking, private for restricting access, this for referring to the current object, break to exit loops, double for floating-point numbers, implements for implementing interfaces, protected for restricting access, throw for throwing exceptions, byte for 8-bit integer, else for alternative code blocks,
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Keywords in Java Description
A class that is declared with abstract keyword, is known as abstract
abstract class in java. It can have abstract and non-abstract methods (method with body). It is is allowed only inside a loop body. When continue executes, the continue current iteration of the loop body terminates, and execution continues with the next iteration of the loop. For is used for looping. It involves initialization, a boolean expression, and incrementation/decrementation. It supports repeated execution of a for statement or block of statements that is controlled by an iterable expression. new used to create an instance of a class, or an object. switch Used as a statement which executes when it matches to a specific case. Assert keyword is added in 1.4 version. It describes a predicate (true- assert false statement), to let developers think that it’s always true. If an assertion is false at run-time, it causes execution to abort. default Used in a switch statement to execute a block of code in the loop. goto goto has no function and it is no more supported in Java programming. package is a mechanism of grouping similar type of classes, interfaces, package and sub-classes collectively based on functionality. Synchronized blocks in Java are marked with the Synchronized keyword. This block in Java is synchronized on some object. All blocks synchronized that are synchronized on the same object can only have one thread executing inside them at a time. boolean boolean can hold true or false value only. It is used in control statements. The Java do-while loop is used to iterate do a set of statements until the given condition is satisfied. If statement is used to test an expression and execute certain if statements accordingly. It is also used to create an if-else statement in java. Private is an access modifier in java, where the methods or data private members that are declared as private are only accessible within the class in which they are declared. this keyword in Java represents the current instance of a class. It is this mainly used to access other members of the same class. The break statement is allowed only inside a loop body. When break break executes, the loop terminates. double It declares a variable that can hold 64-bit double floating-point numbers. implements used by a class to implements an interface. The methods or data members that are declared as private are only protected accessible within the class in which they are declared. throw used to create and throw an exception. byte It is used to declare a field which can hold 8-bit data values. else It is used to implement a condition alternate to if condition. import Used in the beginning which refers to other classes Classes, methods or data members which are declared as public are public accessible anywhere throughout the program. There is no restriction on the scope of public data members. Used in method declarations which specifies exceptions that can’t be throws handled within the method. used in the switch statements which can be labeled with one or more case case enum Enum is added in 5.0 version. It evaluates to true if and only if the runtime type of the object is instanceof compatible with the class or interface. Used to finish the execution of a method. It returns the value required by return the method. It declares an instance field which is not a part of the default serialized transient form of an object. Statements in the catch block specify the exceptions generated by try catch block. extends Merely indicates that a class has extended its immediate class. int A data type that holds 32 bit signed integer. short A data type that holds a 16-bit integer. try It tests a block of code for exceptions. char It is a data type that can hold a 16-bit unsigned integer. Once a certain entity is defined, it cannot be changed nor derived from final later. Interface in Java refers to the abstract data types. They allow Java interface collections to be manipulated independently from the details of their representation. static keyword is mainly used for memory management. It can be used static with variables, methods, blocks and nested classes. void It returns a null value for a method. It creates a new class in Java which is a blueprint from which class an object is created. It specifies that a block of code under exception handling always gets finally executed. long Data type holding a 64 bit integer. strictfp strictfp keyword is added in 1.2 version. volatile Specifies or indicates that a variable might change asynchronously. const This const java keyword is no more used. float A data type holding a 32-bit floating point number. It specifies that a method declaration has tobe done from platform- native specific(native) code. super keyword refers to the members such as variable,method and super constructor of of immediate super class. It is used to create while loop.The Java while loop is used to iterate a while part of the program again and again. If the number of iteration is not fixed, then you can use while loop.