While Loop
While Loop
While Loop:
In a "while" loop, the condition is tested before the loop body is executed. If the
condition is initially false, the loop body may never execute.
It's known as an entry-controlled loop because the condition is checked at the
beginning, and if it's false, the loop doesn't execute at all.
Do-While Loop:
In a "do-while" loop, the loop body is executed at least once, and then the
condition is checked. If the condition is false, the loop terminates.
It's known as an exit-controlled loop because the loop is executed once before
checking the condition.
2. Then test expression is evaluated. If its value is non zero the loop is terminated without
expression.
1.Public: Members marked as "public" are accessible from anywhere, both within and
outside the class. They have the widest visibility. This means that you can access these
members from other classes, even if they are in different packages or modules.
Example (Java):
public class MyClass {
public int publicField;
public void publicMethod() {
}
}
2.Protected: Members marked as "protected" are accessible within the class, its subclasses, and
within the same package (package-level visibility). This allows for a controlled level of access for
class hierarchies and related classes.
public class MyClass {
protected int protectedField;
protected void protectedMethod() {
}
}
3.Default : Members without an explicit access modifier (i.e., no "public," "private," or
"protected" keyword) are accessible within the same package but not from outside it.
class MyClass {
int defaultField;
void defaultMethod() {
// ...} }
4. Private: Members marked as "private" are only accessible within the class where
they are declared. They are not visible or accessible from outside the class. This provides
the highest level of encapsulation and information hiding.
Example (Java):
8. The ORDER BY clause is used in SQL (Structured Query Language) to sort the
result set of a query based on one or more columns in ascending or descending
order. It is commonly used with the SELECT statement to retrieve data from a
database and display the results in a specific order.
FROM table_name
charAt:
The charAt method is a member of the java.lang.String class.
It is used to retrieve the character at a specific index within a string.
The index is zero-based, so the first character is at index 0, the second at index 1,
and so on.
Syntax:
String str = "Hello, World";
char character = str.charAt(7);
System.out.println(character);
getChars:
The getChars method is a member of the java.lang.String class.
It is used to copy characters from a specific range within a string into a character
array.
srcBegin and srcEnd specify the range of characters to copy from the string.
dst is the destination character array where the characters will be copied.
dstBegin is the starting index in the destination array where the characters will be
placed.
Syntax:
String str = "Java Programming";
char[] charArray = new char[6];
str.getChars(5, 11, charArray, 0);
System.out.println(charArray);