Question
Question 1: -- Consider the examples below: a string. 'a string'. a string. 1234. integer. Which could be the value of a Java variable of
Question 1: -- Consider the examples below: a string. 'a string'. "a string". "1234". integer. Which could be the value of a Java variable of type String? A and B. B and E. B and C. C and D.
Flag this Question
Question 2: -- An anonymous String ________. has no value is a string literal can be changed none of the above Flag this Question
Question 3: -- A String constructor cannot be passed in ________. char arrays. int arrays. byte arrays. Strings. Flag this Question
Question 4: -- String objects are immutable. This means they ________. must be initialized cannot be deleted cannot be changed None of the above Flag this Question
Question 5: -- The length of a string can be determined by ________. the String method length() the String instance variable length the String method strlen() All of the above. Flag this Question
Question 6: -- The statement s1.equalsIgnoreCase(s4) is equivalent to which of the following? s1.regionMatches(true, 0, s4, 0, s4.length()); s1.regionMatches(0, s4, 0, s4.length()); s1.regionMatches(0, s4, 0, s4.length); s1.regionMatches(true, s4, 0, s4.length); Flag this Question
Question 7: -- The statement s1.startsWith("art") has the same result as which of the following? s1.regionMatches(0, "art", 0, 3); s2 = s1.getChars(0, 3); s2.equals("art"); s1.regionMatches(true, 0, "art", 0, 3); All of the above Flag this Question
Question 8: -- For String c = "hello world"; The Java statements int i = c.indexOf('o'); int j = c.lastIndexOf('l'); will result in: i = 4 and j = 8. i = 5 and j = 8. i = 4 and j = 9. i = 5 and j = 9. Flag this Question
Question 9: -- For String c = "Hello. She sells sea shells"; The Java statements int i = c.indexOf("ll"); int j = c.lastIndexOf("ll"); will result in: i = 2 and j = 24. i = 3 and j = 24. i = 2 and j = 25. i = 3 and j = 23. Flag this Question
Question 10: -- The String method substring returns ________. a char a String void a char[] Flag this Question
Question 11: -- Consider the statements below: String a = "JAVA: "; String b = "How to "; String c = "Program"; Which of the statements below will create the String r1 = "JAVA: How to Program"? String r1 = c.concat(b.concat(a)); String r1 = a.concat(b.concat(c)); String r1 = b.concat(c.concat(a)); String r1 = c.concat(c.concat(b)); Flag this Question
Question 12: -- Which of the following is not a method of class String? toUpperCase trim toCharacterArray All of the above are methods of class String Flag this Question
Question 13: -- StringBuilder objects can be used in place of String objects if ________. the string data is not constant the string data size may grow the programs frequently perform string concatenation All of the above. Flag this Question
Question 14: -- Given the following declaration: StringBuilder buf = new StringBuilder(); What is the capacity of buf? 0 10 16 20 Flag this Question
Question 15: -- Which of the following statements is true? The capacity of a StringBuilder is equal to its length The capacity of a StringBuilder cannot exceed its length. The length of a StringBuilder cannot exceed its capacity. Both a and b are true. Flag this Question
Question 16: -- Given the following declarations: StringBuilder buffer = new StringBuilder(Testing Testing); buffer.setLength(7); buffer.ensureCapacity(5); Which of the following is true? buffer has capacity 5. buffer has capacity 31. buffer has content Testing. buffer has length 15. Flag this Question
Question 17: -- To find the character at a certain index position within a String, use the method getChars, with the index as an argument getCharAt, with the index as an argument charAt, with the index as an argument charAt, with the character you are searching for as an argument Flag this Question
Question 18: -- Consider the Java segment: String line1 = new String("c = 1 + 2 + 3") ; StringTokenizer tok = new StringTokenizer(line1); int count = tok.countTokens(); The value of count is ________. 8 7 13 4 Flag this Question
Question 19: -- Which of the following statements is false? Storage of data variables and arrays is temporary. Data is lost when a local variable goes out of scope. Files are used for long-term retention of large amounts of data. Data maintained in files is often called transient data. Flag this Question
Question 20: -- Streams that input bytes from and output bytes to files are known as ________. bit-based streams byte-based streams character-based streams Unicode-based streams Flag this Question
Question 21: -- Class ________ provides static methods for common file and directory manipulations, including methods for copying files; creating and deleting files and directories; getting information about files and directories; reading the contents of files; getting objects that allow you to manipulate the contents of files and directories; and more. File FileAndDirectory Files FilesAndDirectories Flag this Question
Question 22: -- A(n) ________ path starts from the directory in which the application began executing. absolute relative parallel comparative Flag this Question
Question 23: -- Path method ________ returns the String name of a file or directory without any location information. getStringName getFileOrDirectoryName getDirectoryName getFileName Flag this Question
Question 24: -- Which statement regarding Java files is false? Java imposes no structure on a file. Notions like record do not exist in Java files. The programmer must structure files to meet the requirements of applications. Records in a Java sequential file are stored in order by record key. Flag this Question
Question 25: -- What does the following statement do?
Scanner scanner = new Scanner(Paths.get("test.txt"));
Opens a binary file for input. Opens a binary file for output. Opens a text file for input. Opens a text file for output. Flag this Question
Question 26: -- Which of the following statements is true? Class Scanner provides the ability to reposition to the beginning of a file with method seek. Class Scanner provides the ability to reposition to the beginning of a file with method reposition. Class Scanner does not provide the ability to reposition to the beginning of the file. If it is necessary to read a sequential file again, the program can simply keep readingwhen the end of the file is reached, the Scanner is automatically set to point back to the beginning of the file. Flag this Question
Question 27: -- Which of the following classes enable input and output of entire objects to or from a file? SerializedInputStream SerializedOutputStream ObjectInputStream ObjectOutputStream Scanner Formatter
A and B. C and D. C, D, E, F. E and F. Flag this Question
Question 28: -- What interface must a class implement to indicate that objects of the class can be output and input as a stream of bytes? Synchronize Deserializable Serializable ObjectOutput Flag this Question
Question 29: -- Which JFileChooser method returns the file the user selected? getSelectedFile. getFile. getOpenDialog. showOpenDialog. Flag this Question
Question 30: -- The ________ abstract classes are Unicode character-based streams. Reader and Writer BufferedReader and BufferedWriter CharArrayReader and CharArrayWriter UnicodeReader and UnicodeWriter Flag this Question
Question 31: -- Which of the following is not a GUI component (control or widget)? String. Button. Menu. Combo box. Flag this Question
Question 32: -- Which component contains menus? Menu button. Title bar. Menu bar. Combo box. Flag this Question
Question 33: -- Which of the following is the method used to display a dialog box to gather input? showMessageDialog. getInput. inputDialog. showInputDialog. Flag this Question
Question 34: -- The JOptionPane constant used to display an icon prompting the user for input is: JOptionPane.ERROR_MESSAGE. JOptionPane.INFORMATION_MESSAGE. JOptionPane.QUESTION_MESSAGE. JOptionPane.WARNING_MESSAGE. Flag this Question
Question 35: -- Together, the appearance and the way in which the user interacts with the application are known as that applications ________. abstract window toolkit. look-and-feel. swing factor. All of the above. Flag this Question
Question 36: -- Which of the following statements about heavyweight components is false? AWT components are not heavyweight components. Several Swing components are heavyweight components. The look-and-feel may vary across platforms. The functionality may vary across platforms. Flag this Question
Question 37: -- provides the basic attributes and behaviors of a windowa title bar at the top of the window, and buttons to minimize, maximize and close the window. JLabel. JFrame. JSwing. JWindowControl. Flag this Question
Question 38: -- A JLabel can be attached to a JFrame using method ________. attach contain append add Flag this Question
Question 39: -- Which JFrame constant indicates that the program should terminate when the window is closed by the user? TERMINATE_ON_CLOSE. IMMEDIATELY_CLOSE. EXIT_ON_CLOSE. All of the above. Flag this Question
Question 40: -- Which of the following statements makes the text in a JTextField uneditable? textField.setEditable(true); textField.setEditable(false); textField.setUneditable(true); textField.setUneditable(false); Flag this Question
Question 41: -- When the user presses Enter in a JPasswordField, the GUI component generates and, which is processed by an object that implements the interface. ActionEvent, ActionListener. ActionEvent, ActionEventListener. TextEvent, TextListener. TextEvent, TextEventListener. Flag this Question
Question 42: -- JPasswordField contains a method to obtain the data entered. getInput. getPassword. getText. getEcho. Flag this Question
Question 43: -- The method setRolloverIcon is used to ________. Handle a key event Change the button text Change the button icon All of the above Flag this Question
Question 44: -- Two tasks that are operating ________ are both making progress at once. sequentially concurrently iteratively recursively Flag this Question
Question 45: -- Two tasks that are operating ________ are executing simultaneously. concurrently in parallel sequentially iteratively Flag this Question
Question 46: -- A new thread begins its life cycle by transitioning to the __________ state. runnable. waiting. terminated. new Flag this Question
Question 47: -- A waiting thread transitions back to the ________ state only when another thread notifies it to continue executing. runnable terminated new blocked Flag this Question
Question 48: -- A runnable thread enters the ________ state (sometimes called the dead state) when it successfully completes its task or otherwise terminates (perhaps due to an error). extinct defunct terminated aborted Flag this Question
Question 49: -- With timeslicing, each thread is given a limited amount of time, called a __________, to execute on a processor. quantum burst time allocation scheduling interval Flag this Question
Question 50: -- Its recommended that you do not explicitly create and use Thread objects to implement concurrency, but rather use the ________ interface. ExecutorService Runnable Concurrent Executor Flag this Question
Question 51: -- When a higher-priority thread enters the ready state, the operating system generally preempts the currently running thread (an operation known as preemptive scheduling). Depending on the operating system, a steady influx of higher-priority threads could postponepossibly indefinitelythe execution of lower-priority threads. such indefinite postponement is sometimes referred to more colorfully as________.
fasting famine starvation malnourishment Flag this Question
Question 52: -- Operating systems employ a technique called ________ to prevent indefinite postponementas a thread waits in the ready state, the operating system gradually increases the threads priority to ensure that the thread will eventually run.
incrementing prioritizing maturing aging Flag this Question
Question 53: -- Another problem related to indefinite postponement is called ________. This occurs when a waiting thread (lets call this thread1) cannot proceed because its waiting (either directly or indirectly) for another thread (lets call this thread2) to proceed, while simultaneously thread2 cannot proceed because its waiting (either directly or indirectly) for thread1 to proceed. The two threads are waiting for each other, so the actions that would enable each thread to continue execution can never occur.
impass standoff deadlock stalemate Flag this Question
Question 54: -- The preferred means of creating multithreaded Java applications is by implementing the ________ interface. An object of a class that implements this interface represents a task to perform. Thread Runner Runnable None of the above. Flag this Question
Question 55: -- When a __________ method or block is running on an object, the object is locked so no other such method can run on that object at the same time. synchronized shared thread writeable
NOTE: -- plz give all the MCQ's answers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started