JAVA test on P6
- Question 1. Which line is wrong?
1. int i = 0;
2. due to {
3. i + = 1;
4.} while (i == 0);
5. System.out.println ('i =' + i);- first
- 2 and 3
- 4
- No wrong lines
-
- Question 2. s is the result of how much when executing the command block?
int i = 0;
int s = 0;
for (;;) {
if i == 3 break;
s = s + i;
i ++;
}- 6
- 3
- Program reported an error
- 0
-
- Question 3. In what line is the program wrong?
1. int i = 0;
2. int s = 0;
3. for (;;) {
4. if i == 3 break;
5. s = s + i;
6. i ++;
7.}- 1 and 2
- 4
- 6
- No wrong lines
-
- Question 4. What is the result of the program?
BreakDemo class {
public static void main (String [] args) {
int [] arrayOfInts = {32, 87, 3, 589, 12, 1076, 2000, 8, 622, 127};
int searchFor = 12;
int i;
boolean fountIt = false;
for (i = 0; i
if (arrayOfInts [i] == searchFor) {
fountIt = true;
break;
}
}
if (fountIt) {
System.out.println ('Found' + searchFor + 'at index' + i);
} else
System.out.println (searchFor + 'not in the array');
}
}- 12 không phải trong mảng
- Found 12 at index 4
- Program error
-
- Found it
-
- Question 5. Which line is wrong?
1. BreakDemo class {
2. public static void main (String [] args) {
3. int [] arrayOfInts = {32, 87, 3, 589, 12, 1076, 2000, 8, 622, 127};
4. int searchFor = 12;
5. int i;
6. boolean fountIt = false;
7. for (i = 0; i
8. if (arrayOfInts [i] == searchFor) {
9. fountIt = true;
10. break;
11.}
twelfth. }
13. if (fountIt) {
14. System.out.println ('Found' + searchFor + 'at index' + i);
15.} else
16. System.out.println (searchFor + 'not in the array');
17.}
18.}- 2 and 6
-
- 3 and 11, 15
-
- 5, 7, 9
- No programs are wrong
-
- Question 6. What does the program do?
BreakDemo class {
public static void main (String [] args) {
int [] arrayOfInts = {32, 87, 3, 589, 12, 1076, 2000, 8, 622, 127};
int searchFor = 12;
int i;
boolean fountIt = false;
for (i = 0; iif (arrayOfInts [i] == searchFor) {
fountIt = true;
break;
}
}
if (fountIt) {
System.out.println ('Found' + searchFor + 'at index' + i);
} else
System.out.println (searchFor + 'not in the array');
}
}- Find an element in the array
-
- Compare array elements together.
- Calculate the total array.
- All answers are wrong
-
- Question 7. What does the following program do?
class ContinueDemo {
public static void main (String [] args) {
String searchMe = 'peter piper picked up a peck of pickled peppers';
int max = searchMe.length ();
int numPs = 0;
for (int i = 0; i
if (searchMe.charAt (i)! = 'p') continue;
numPs ++;
}
System.out.println ('Found' + numPs + 'p's in the string.');
}
}- Count the letter p in the character string
- Find out if the p is in front of the letter i in the string
- Search for letter p in the string
- All is wrong
-
- Question 8. What is the result of the following program?
class ContinueDemo {
public static void main (String [] args) {
String searchMe = 'peter piper picked up a peck of pickled peppers';
int max = searchMe.length ();
int numPs = 0;
for (int i = 0; i
if (searchMe.charAt (i)! = 'p')
tiếp tục;
numPs ++;
}
System.out.println ('Found' + numPs + 'p's in the string.');
}
}-
- Found 9 p's in the string.
- Found 8 p's in the string.
- Found 10 p's in the string.
- There is no right answer.
-
- Question 9. What is the result of the following program?
class ContinueDemo {
public static void main (String [] args) {
String searchMe = 'peter piper picked up a peck of pickled pepers';
int max = searchMe.length ();
int numPs = 0;
for (int i = 0; i
if (searchMe.charAt (i)! = 'p')
tiếp tục;
numPs ++;
}
System.out.println ('Found' + numPs + 'p's in the string.');
}
}- Found 9 p's in the string.
- Found 8 p's in the string.
- Found 10 p's in the string.
- There is no right answer.
-
- Question 10. Which method of the String class returns the index of the child string that appears first in the char character string '
- concat ()
- charAt ()
- indexOf ()
- There is no right answer.
-
5 ★ | 1 Vote
You should read it
May be interested
- Test on JAVA test on P9unlike most common programming languages, instead of compiling the source code into machine code or interpreting source code when running, java is designed to compile the source code into bytecode, then bytecode will be run by the runtime environment. . to help you better understand this programming language, the following quiz of network administrator will give you lots of useful knowledge.
- Get familiar with NetBeans Java IDEin the following article, we will introduce you the most basic features of netbeans ide through a small test, which is to create the 'hello world' java application. and when finished, you will know the general knowledge and process when programming applications in ide ...
- Testing test on JAVA P2multiple choice questions on java programming help you test your basic knowledge of this programming language. the set of questions includes 10 sentences to try.
- JAVA P8 test quizif you are interested in learning about the java programming language, the following quiz of network administrator will provide you with a lot of useful knowledge for your learning.
- Basic Java syntaxa java program can be defined as a collection of objects, communicating through calling each other's procedures. now we will look at the class, object, procedure and instance variable / instance variable to consider their meaning.
- eQuiz - Multiple choice test on Java Swing Practicewelcome to the test series of tipsmake.com with topics related to the fields of information technology. and this time we will continue with the java swing practice test, a total of 13 questions will be answered with no time to answer each sentence. there will be some questions with many different answer options
- What is JAVA file? How to open, edit and convert JAVA filesa file with a .java extension is (or sometimes also used in .jav format) is a java source file written in the java programming language.
- eQuiz - Multiple choice quiz about JAVAfollowing are multiple-choice questions related to java programming language, there will be 23 questions in total with no answer for each time. let's get started!
- Download and install Java on the computerto program java on your computer, you need to install the java environment, this tutorial will show you how to download and install java on your computer.
- Basic Java exercises, with sample decodingto serve your java learning needs, tipsmake.com has synthesized some java exercises from many sources, including sample code (for some articles). hopefully it can be helpful to learn your java programming language.