The normalize() method removes redundant name elements from a qualified path.


1. Which of the following correctly defines a StringBuilder?
    There is no such thing as a StringBuilder in Java.
    A method that adds characters to a string.
    A class that represents a string-like object. [*]
    A class inside the java.util.regex package.

2. What class is the split[] method a member of?
    String [*]
    Parse
    Array
    StringBuilder

3. Which of the following correctly initializes a StringBuilder?
   StringBuilder sb = "This is my String Builder";
   StringBuilder sb = StringBuilder[500];
   StringBuilder sb = new StringBuilder[]; [*]
   None of the above.

4. Using the FOR loop method of incrementing through a String is beneficial if you desire to: [Choose Three]
   Parse the String. [*]
   Search for a specific character or String inside of the String. [*]
   Read the String backwards [from last element to first element]. [*]
   You don't use a FOR loop with Strings

5. Which case handles the last recursive call?
    The convergence case
    The secondary case
    The primary case
    The base case [*]
    The recursive case

6. A non-linear recursive method is less expensive than a linear recursive method.
True or false?
    True
    False [*]

7. Which two statements can create an instance of an array? [Choose Two]
    double da = new double [5];
    Object oa = new double[5]; [*]
    char[] ca = "java";
    int[] ia = new int [5]; [*]
    int ia[][] = [1,2,3] [4,5,6];

8. Forward thinking helps when creating linear recursive methods.
True or false?
    True
    False [*]

9. Your teacher asks you to write a segment of code that returns true if String str contains zero or one character[s] and false otherwise. Which of the following code segments completes this task?[Choose Two]
    return str.contains["."];
    return str.matches["[a-z]*"];
    if[ str.length[] == 0 || str.length[] == 1]
       { return true;}
       return false; [*]
   return str.matches[".?"]; [*]

10. Consider that you are writing a program for analyzing feedback on the video game you have developed. You have completed everything except the segment of code that checks that the user's input, String userI, is a valid rating. Note that a valid rating is a single digit between 1 and 5 inclusive. Which of the following segments of code returns true if the user's input is a valid rating?[Choose Two]
     return userI.matches["[1-5].*"];
     return userI.matches["{1-5}"];
     return userI.matches["[1-5]"]; [*]
     return userI.matches["[1-5]{1}"]; [*]

11. The following code correctly initializes a pattern with the regular expression "[0-9]{2}/[0-9]{2}/[0-9]{2}".
Pattern dateP = Pattern.compile["[0-9]{2}/[0-9]{2}/[0-9]{2}"];
True or false?
      True [*]
       False

12. Which of the following does not correctly match the regular expression symbol to its proper function?
"{x}" means there must be x occurrences of the preceding character in the string to be a match.
"?" means there may be zero or one occurrences of the preceding character in the string to be a match.
"+" means there may be zero or more occurrences of the preceding character in the string to be a match. [*]
"{x,}" means there may be x or more occurrences of the preceeding character in the string to be a match.
"{x,y}" means there may be between x and y occurrences of the preceding character in the string to be a match.

13. What is the function of the asterisk [*] in regular expressions?
      The asterisk has no function in regular expressions.
      Indicates that the preceding character may occur 1 or more times in a proper match.
      Indicates that the preceding character may occur 0 or 1 times in a proper match.
      Indicates that the preceding character may occur 0 or more times in a proper match. [*]

14. Square brackets are a representation for any character in regular expressions "[ ]".
True or false?
       True
       False [*]

15. Which of the following correctly defines a repetition operator?
A symbol that represents any character in regular expressions.
A method that returns the number of occurrences of the specified character.
symbol in regular expressions that indicates the number of occurrences a specified character appears in a matching string. [*]

16. Which statement added at line one allows the code to compile and run?
//line one
public class Test [
  public static void main [String[] args] {
   java.io.PrintWriter out = new java.io.PrintWriter
        [new java.io.OutputStreamWriter [System.out], true];
   System.out.println["Java"];
  }
}
  include java.io.*;
  import java.io.OutputStreamWriter
  No statement is needed. [*]
  import java.io.PrintWriter;
  import java.io.*;

17. What is one step you must do to create your own exception?
     Declare the primitive data type Exception.
    Create a new class that implements Exception.
    Create a new class that extends Exception. [*]
    Exceptions cannot be created. They are only built in to Java.

18. Methods can not throw exceptions.
True or false?
    True
    False [*]

19. What is the output from the following code?
public class Foo{
  public static void main[String[] args]{
   try {return;}
   finally{System.out.println["you are in Finally"];}
 }
}
The code compiles and prints out モyou are in Finally" [*]
The code will not compile.
The code compiles and print nothing
The code compiles, but an exception is thrown.

20. In what order do multiple catch statements execute?
The order they are declared in [ most specific first]. [*]
They all execute at the same time.
The order they are declared in [most general first].
None of them execute since you cannot have multiple catch statements.

21. Multiple exceptions can be caught in one catch statement.
True or false?
True [*]
False

22. The finally clause only executes when an exception is not caught and thrown.
True or false?
True
False [*]

23. Which of the following is an absolute Windows path?
/data
\Users\UserName\data
/home/user/username
C:\Users\UserName\data [*]

24, Prior to Java 7, you write to a file with a call to the BufferedWriter class's write[] method.
True or false?
True [*]
False

25. An absolute path always starts from the drive letter or mount point.
True [*]
False

26. The normalize[] method removes redundant name elements from a qualified path.
True or false?
True [*]
False

27. The Paths class provides a static get[] method to find a valid Path.
true or false?
True [*]
False

28. Which statement determine that "java" is a directory?
Boolean isDir=[new File["java"]].isDir[];
Boolean isDir=Directory.exists ["java"];
Boolean isDir=[new Directory["java"]].exists[]; [*]
Boolean isDir=[new File["java"]].isDirectory[];

29. The System.out is what type of stream?
A PrintStream [*]
A BufferedReader stream
A Reader stream
A BufferedWriter stream
An OutputStream

30. The Files class provides a instance method that creates a new BufferedReader.
True or false?
True [*]
False

31. Which of the following files are not required to be uploaded to a web server to deploy a JWS java application/applet?
jar files
JNLP files
html files
.java files [*]
None of the above

32. Which of the following is an attribute of a three tier architecture application?
an application of that type has a client and server only
an complex application that includes a client, a server and database [*]
an application of that type runs on a single computer
None of the above
All of the above

33. The method for connecting a Java application to a database is by using:
jar files
JNLP
JDBC [*]
Java Web Start
None of the above

34. Java Web Start is used to deploy Java applications.
True or false?
True [*]
False

35. Which of the following is an attribute of a two tier architecture application?
An application of that has a client and server only. [*]
A complex application that includes a client, a server and database.
An application of that runs on a single computer.
None of the above.

36. Which of the following is not a reason to use a Java package?
It is a way to organize files when a project consists of multiple modules.
It is a way to help resolve naming conflicts when different packages have classes with the same sames.
It is a way to protect data from being used by the non-authorized classes.
It is a way to allow programmers to receive packets of information from databases. [*]
None of the above

37. When you import a package, subpackages will not be imported.
True or false?
True [*]
False

38. A jar file is built on the ZIP file format and is used to deploy java applets.
True or false?
True [*]
False

39. What option do you choose from the File menu in Eclipse to start the process of creating a runnable JAR file?
Export [*]
Switch Workspace
Properties
Import

40. The method for connecting a java application to a database is JNLP.
True or false?
An example of two tier architecture would be a client application working with a server application.
True or false?
True [*]
False

41. To deploy java applications you may use Java Web Start.
True or false?
True [*]
False

42. Which of the following are files that must be uploaded to a web server to deploy a Java application/applet?[Choose Three]
jar files [*]
JNLP files [*]
html files [*]
.java files
None of the above

43. How would you make an instance of Car in a class that didn't import the vehicle package below?
package vehicle;
public class Car{
 public Car[]{}
}
Car c = new Car[];
vehicle.Car c=new Car[];
vehicle.Car c=new vehicle.Car[]; [*]
vehicle.Car c=new vehicle[];
None of the above

44. If a class is in a package, the system's CLASSPATH must be altered to access the class.
True or false?
True
False [*]

45. An example of two tier architecture would be a client application working with a server application.
True or false?
True [*]
False

46. Which two statements can create an instance of an array? [Choose Two]
double da = new double [5];
Object oa = new double[5]; [*]
char[] ca = "java";
int[] ia = new int [5]; [*]
int ia[][] = [1,2,3] [4,5,6];
A non-linear recursive method can call how many copies of itself?
12 or more [*]
None
 linear recursive method can call how many copies of itself?
1 [*]
2 or more
None
he base case condition can work with a constant or variable.
True or false?
True [*]
False
Which of the following correctly defines a repetition operator?
A symbol that represents any character in regular expressions.
A method that returns the number of occurrences of the specified character.
symbol in regular expressions that indicates the number of occurrences a specified character appears in a matching string. [*]
None of the above.
Matcher has a find method that checks if the specified pattern exists as a sub-string of the string being matched.
True or false?
True [*]
False
Consider designing a program that organizes your contacts alphabetically by last name, then by first name. Oddly, all of your contacts' first and last names are exactly five letters long.
Which of the following segments of code establishes a Pattern namePattern with a group for the first name and a group for the last name considering that the string contactsName is always in the format lastName_firstName?
Pattern namePattern = Pattern.compile["[.{5}]_[.{5}]"]; [*]
Pattern namePattern = Pattern.compile["first_last"];
Pattern namePattern = new Pattern[last{5},first{5}];
Pattern namePattern = new Pattern[];
None of the above.
Square brackets are a representation for any character in regular expressions "[ ]".
True or false?
True
False [*]
Which of the following correctly defines Matcher?
A class in the java.util.regex package that stores the matches between a pattern and a string. [*]
A regular expression symbol that represents any character.
A method of dividing a string into a set of sub-strings.
A class in the java.util.regex package that stores the format of a regular expression.
What does the dot [.] represent in regular expressions?
An indication for one or more occurrences of the preceding character.
A match for any character. [*]
A range specified between brackets that allows variability of a character.
Nothing, it is merely a dot.
Which of the following are true about parsing a String?[Choose Three]
It is possible to use a for loop to parse a string. [*]
It is possible to use the String.split[] method to parse a string. [*]
It is not possible to parse a string using regular expressions.
It is a way of dividing a string into a set of sub-strings. [*]
Consider that you are making a calendar and decide to write a segment of code that returns true if the string month is April, May, June, or July. Which code segment correctly implements use of regular expressions to complete this task?
return month.equals["April, May, June, July"];
return month.compareTo["April, May, June, July"];
return month.matches["April|May|June|July"]; [*]
return month.matches["April"|"May"|"June"|"July"];
return month.substring[0,3];
Consider designing a program that organizes your contacts alphabetically by last name, then by first name. Oddly, all of your contacts' first and last names are exactly five letters long.
Which of the following segments of code establishes a Pattern namePattern with a group for the first name and a group for the last name considering that the string contactsName is always in the format lastName_firstName?
Pattern namePattern = Pattern.compile["[.{5}]_[.{5}]"]; [*]
Pattern namePattern = Pattern.compile["first_last"];
Pattern namePattern = new Pattern[last{5},first{5}];
A regular expression is a character or a sequence of characters that represent a string or multiple strings.
True or false?
True [*]
False
Which of the following methods for the String class take a regular expression as a parameter and returns true if the string matches the expression?
equals[String regex]
equalsIgnoreCase[String regex]
compareTo[String regex]
matches[String regex] [*]
What is the result from the following code?
public class Test {
    public static void main[String[] args] {
     String str = "91204";
     str += 23;
     System.out.print[str];
    }
}

23
91204
91227
9120423 [*]
Which of the following correctly initializes a StringBuilder?
StringBuilder sb = "This is my String Builder";
StringBuilder sb = StringBuilder[500];
StringBuilder sb = new StringBuilder[]; [*]
None of the above.
Which of the following are true about parsing a String?[Choose Three]
It is a way of dividing a string into a set of sub-strings. [*]
It is possible to use the String.split[] method to parse a string. [*]
It is possible to use a for loop to parse a string. [*]
It is not possible to parse a string using regular expressions.
Which of the following methods are StringBuilder methods?
append
delete
insert
replace
All of the above. [*]
A linear recursion requires the method to call which direction?
Forward
Backward [*]
Both forward and backward
None of the above
A non-linear recursive method is less expensive than a linear recursive method.
True or false?
True
False [*]
A linear recursive method can call how many copies of itself?
1 [*]
2 or more
None
Forward thinking helps when creating linear recursive methods.
True or false?
True
False [*]
File permissions are the same across all of the different operating systems.
True
False[*]
The BufferedInputStream is a direct subclass of what other class?
InputStream
FileInputStream
PipedInputStream
 FilterInputStream[*]
InputStream
You can read input by character or line.
TRue or false?
True[*]
False
When will a finally statement be executed?
Only if an exception is not thrown.
Always; no matter if an exception is thrown or not. [*]
Only if an exception is thrown.
Only if multiple exceptions are caught and thrown.
Never; it is there for visual purposes.
Which of the following is the correct way to throw cumstom ServerException?
throws ServerException
throw new ServerException[] [*]
throw ServerException
raise ServerException
What is the definition of a logic error?
Bugs in code that make your program run different than expected [*]
Computer malfunction that makes your code run incorrectly.
Something that causes your computer to crash.
Wrong syntax that will be caught at compile time.
What is the output from the following code snippet?
public static void main[String[] args]{
 try{
  String[] s=null;
   s[0]="Java";
   System.out.println[s[0]];
  }catch[Exception e] {
   System.out.println["Exception"];
  }catch[NullPointerException e]{
   System.out.println["NullPointerException"];
 }
NullPointerException
Java
Compile fails [*]
Exception
What symbol[s] is used to separate multiple exceptions in one catch statement?
none, multiple exceptions can't be handled in one catch statement.
[==] [equals equals]
A single vertical bar | [*]
&&
The way that you read from a file has changed since the introduction of Java 7.
True or false?
True [*]
False
Prior to Java 7, you write to a file with a call to the BufferedWriter class's write[] method.
True or false?
True [*]
False
Which of these construct a DataInputStream instance?
New dataInputStream[new writer["java.txt"]];
New dataInputStream[new InputStream["java.txt"]];
New dataInputStream["java.txt"];
New dataInputStream[new FileInputStream["java.txt"]]; [*]
New dataInputStream[new file["java.txt"]];
The new Paths class lets you resolve .. [double dot] path notation.
True or false?
True[*]
False
Prior to Java 7, you write to a file with a call to the BufferedWriter class's write[] method.
True or false?
True[*]
False
The java.io package has problems with no support for symbolic links.
True or false?
True[*]
False
Which three types of objects can be thrown using a throw statement? [Choose Three]
Object
Event
Error [*]
Throwable [*]
Exception [*]
Why should you not use assertions to check parameters?
It is hard to assume expected values for parameters.
Assertions can be disabled at run time which may cause unexpected results in your assertions. [*]
Not all methods have parameters, therefore assertions should never be used on parameters.
Assertions do not work on parameters.
What is exception handling?
A consistent way of handling various errors. [*]
When a file fails to open.
An error that occurs against the flow of your program.
If your program exits before you expect it to
What is the definition of a logic error?
Something that causes your computer to crash.
Computer malfunction that makes your code run incorrectly.
Bugs in code that make your program run different than expected [*]
Wrong syntax that will be caught at compile time.
Assertions are boolean statements to test and debug your programs.
True or false?
True [*]
False
Which statements are true when you compile and run this code.[Choose Two]

1. public class Test{
2.  public static String sayHello[String name] throws Exception{
3.   if[name == null] throw new Exception[];
4.   return "Hello " + name;
5.  }
6.  public static void main[String[] args]{
7.   sayHello["Java"];
8.  }
9. }
can not create Exception object in the Test Class.
The class Test compiles if line 6 contains a throws statement. public static void main[String[] args] throws Exception{ [*]
The class Test compiles if line 7 is enclosed in a try-catch block. try{ sayHello["Java"]; }catch[Exception e]{} [*]
Compilation succeeds
You can read input by character or line.
True or false?
True [*]
False
If a programmer uses the line
import com.test.*,
there is no need to use
import com.test.code.*
True or false?
True
False[*]
The import keyword allows you to access classes of the package without package Fully Qualified Name.
True [*]
False
The import keyword allows you to access classes of the package without package Fully Qualified Name.
True [*]
False
An example of two tier architecture would be a client application working with a server application.
True or false?
True [*]
False
When you import a package, subpackages will not be imported.
True or false?
True [*]
False



Ok-Programming

Add Comment

java

Wednesday, August 8, 2018

Share

Like

G+

Tweet

Tweet

Related Posts

    Chủ Đề