selection

Share Embed Donate


Short Description

nganggur...

Description

Section 2

1.

Which of the following three statements are true about breakpoint? They pause code execution They help with debugging. (*) 2. What is the purpose of adding comments in the code ? Provide an explanation about the code to the programmer 3. Which two are the correct syntax for adding comments ? Start with a slash-star (/*). End with a star-slash (*/) Start with two slashes (//). End when the line ends. IDE. Clicking again removes the 4.  A breakpoint can be set by clicking a number in the left margin of the IDE. breakpoint True 5. Code within curly braces is called a “Block of code”  True 6. Java mostly reads code line-by-line True 7. During the Testing phase of software development, which of the following are the tasks undertaken by the programmer? Finding the bugs. Fixing the bugs. 8.  A software feature may allow the user to perform a specific task  True 9. Which of the following are adequate definitions for components of the Spiral Model of Development ? Test: Run the code and verify results (*) Design: Plan the approach (*) 10. The Spiral Model reflects an iterative development process. True 11. In object oriented programming, there is an emphasis on which of the following two: Object interaction without a prescribed order. (*) Modeling objects. 12. Which of the following l anguage is called a procedural language? C 13. There are several fields and methods in a Shirt class. Which of the following could be a method in the Shirt class? GetShirtSize another object by invoking methods 14.  An object may interact with another True 15. In object oriented programming, an object comprises of properties and behaviors where properties represented as fields of the object and behavior is represented as method. True  



 







 



 



 









Section 3 quis 1 1.

What value is assigned to x ? int x = 25 - 5 * 4 / 2 - 10 + 4; 9 Which data type is most commonly used to represent numeric data? Int How many bits are in a byte? 8 

2.



3.



4.

What is the output? public class Person { public static void main(String args[]) { int age = 20; System.out.println("Value of age: " +age); age = 5 + 3; System.out.println("Value of age: " +age); age = age + 1; age++; System.out.println("Value of age: " +age); } }  Value of age: 20  Value of age: 8  Value of age: 10 

5.

Which of the following data types is the largest? Long Which keyword makes a variable’s value unchangeable? Final What is the range of the byte data type? 

6.



7.



8.

 –27 to 27 –1

Which two are mathematical operators? + 9. Which two are valid assignments of a? int a; a = 10; int a = 10; 10.  Assigning a value to the variable is called “initialization”. True 11. Which is valid syntax to declare and initialize a String variable? String x= “Java”; 12. Which two statements will not compile? int break=10; double double=10; 13. Which of the following two statements are true about variables? The allow code to be edited more efficiently. They make code becomes flexible. 14. Which two are valid? double doubleVar1, doubleVar2 = 3.1; (*) double doubleVar1 = 3.1; double doubleVar2 = 3.1; 15. What is the output? public class Hello { public static void main(String args[]) { String str = ”Hello”; str = ”World”; System.out.println(str); } } World  

 





 

 

 



Section 3 quis 2 1.

It's best-practice to close the Scanner stream when finished True 2.  You write a statement that assigns a value to a String variable as shown below. 

String input = ”This is Java Program”; This way of assigning values to variables is known as hard-coding. True System.in readies Scanner to collect input from the console. True What is the output? 

3.



4.

public static void main(String args[]) { String greet1 = "Hello"; String greet2 = "World"; String message2 = greet1 +" " +greet2 +" " +2016 +"!"; System.out.println(message2); } Hello World 2016 ! 5. Double quotes may be used with char literal values. False 6. Which two statements compile? String size = “M”; char size = ’m’; 7. The print() method prints to the console and automatically creates a line. False 8. Which two statements compile? String name = “Java”; String name = “J”; 9.  A String can be created by combining multiple String Literals True 10. Which two statements are correct about the usage of an underscore? Underscores help make large numbers more readable. Underscores do not affect the value of the variable. 11. Which is a valid way to parse a String as an int? int intVar1 = Integer.parseInt("100"); 12. Which exception occurs because a String cannot be parsed as an int? NumberFormatException 13.  Automatic promotion from smaller data type to a larger data type is not allowed in Java. False 14. The Java compiler automatically promotes byte, short, and chars data type values to int data type. True 15.  A short data type can be promoted to which of the following types? Long Double Int 



 



 



 









  

Section 4 quis 1 1.

Which two are valid import statements of the Scanner class? import java.util.*; import java.util.Scanner;  

2.

Given the import statement: import java.awt.font.TextLayout; which is the package name?  java.awt.font The import statement consists of two parts. 

3.

import package.className; One is the package name and the other is the classname. True 4. The JFrame and JOptionPane classes are in the javax.swing package. Which two will import those classes? import javax.swing.JOptionPane; import javax.swing.JFrame; import javax.swing.*; 5. Which statement is true about packages?  A package contains a group of related classes. 6. The classes of the Java class library are organized into packages. True 7. Which of the following wild card character is used to import all the classes in a particular package? * 8. void type methods don’t return any values. True 9. Which of the following two operations are appropriate for the main method? Creating instances of objects Calling an instance object’s field and methods. 10. Once an object is instantiated, how might its fields and methods be accessed in Java? Using the dot(.) operator 11. Which of the following statements are true? Methods can be written with any number of parameters. Parameter values can be used within the method code block. 12. Which of the following scenarios would be ideal for writing a method? When you don’t want to repeat similar lines of code to describe an object’s behavior. 13. Methods allow all instance of a class to share same behaviors. True 14.  You’re designing banking software and need to store 10000 customer accounts with information on the accountholder’s name, balance, and interest rate. The best approach is store 30000 separate variables in the main method. False 15. Which of the following are the arguments in the following method? 100000, 3.2, 15 













 



 









Section 4 quis 4 1.

String objects are immutable. True What is the output of the following code? 

2.

public static void main(String args[]) { String firstString = "Java"; firstString = firstString.concat("World"); System.out.println(firstString); } JavaWorld 

3.

What is the output?

4.

public static void main(String args[]) { String alphaNumeric = "Java World!" + 8; System.out.println(alphaNumeric); } Java World!8 What is the output? 

public static void main(String args[]) { String greeting = "Java World!"; String w = greeting.replace("a", "A"); System.out.println(w); } JAvA World! The replaceFirst() method replaces only the first occurrence of matching character pattern in a string. True Which method returns the length of a String? Length() What is the output? 

5.



6.



7.

public static void main(String args[]) { String greeting = "Java World!"; String w = greeting.substring(7, 11); System.out.println(w); } rld! 8. Which class is used to generate random numbers? Random 9.  You need to generate random integer values between 0 and 80 (inclusive). Which statement should you use? nextInt(81); 10. Using the Random class requires an import st atement. True 11.  You need to generate random integer values in the range 2 through 10. This code fragment will produce the desired result. 







Random r = new Random(); r.nextInt(9) + 2; True 12. What is the package name which contains Math class?  java.lang 13.  A constant field, like Math.PI is used to represent a fixed value. True 14. Which is NOT true? Static methods must be of return void. 15.  All the methods in the Math class are static methods. true 









View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF