0% found this document useful (0 votes)
17 views

While Loop

The document discusses several topics related to Java programming including features of Java, differences between while and do-while loops, differences between ordered and unordered lists, steps to execute a for loop, access specifiers and their categories, the ORDER BY clause in SQL, and differences between charAt and getChars methods.

Uploaded by

Anish Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

While Loop

The document discusses several topics related to Java programming including features of Java, differences between while and do-while loops, differences between ordered and unordered lists, steps to execute a for loop, access specifiers and their categories, the ORDER BY clause in SQL, and differences between charAt and getChars methods.

Uploaded by

Anish Nag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.Features of JAVA language.

1. Java is platform independent language.


2. It is highly reliable.
3. It is object oriented.
4. It is portable.
5. It is distributed.
2.Difference between while loop and do 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.

3. Difference between order list and unorder list.

Ordered List (ol):


 An ordered list is used to create a list of items that should be presented in a
specific numerical or alphabetical order.
 Each item in an ordered list is preceded by a sequential number (or another
marker, depending on the list style).
 By default, ordered lists use Arabic numerals (1, 2, 3, etc.) as markers, but you can
customize the type of numbering or lettering used.
Unordered List (ul):
 An unordered list is used to create a list of items that do not have a specific order
or sequence.
 Each item in an unordered list is typically preceded by a bullet point (or another
marker, depending on the list style).
4. Write the steps how to execute a for loop.

1. Initial expression is evaluated.

2. Then test expression is evaluated. If its value is non zero the loop is terminated without
expression.

3. After the execution of for loop, update expression is evaluated.

4. Body of the loop.


Ex:- Class ForLoop {
Public void main(){
Int I;
for (I = 1; I <= 5; I ++) {
System.out.println(+i),
}
}
}
6. Access specifier(modifire) and its different catagories.
Access specifier controls the accessibility of members in the same class,other class, same
package and other package. It is used to set access levels for classes, variables, methods and
constructors. All the access specifiers are keywords, thereby should be written in lowercase
letters only.
Java offers four types of access specifiers:
1. Public
2. Protected
3. Default
4. Private

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):

public class MyClass {


private int privateField;
private void privateMethod() {
// ...
}
}
7. What is orderby clause? give an example

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.

The basic syntax of the ORDER BY clause is as follows:

SELECT column1, column2, ...

FROM table_name

ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...

9. GetChar and Char At.

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);

RAD- Rapid Application Development


By Defult format of now function -YYYY MM DD
Storage Size of double datatype – 8 bytes

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy