Vous êtes sur la page 1sur 19

Section 2

(Answer all questions in this section)

1. In object oriented programming, there is an emphasis on which of


the following two: Mark for Review
(1) Points

(Choose all correct answers)

Creation of procedures.

Modeling objects. (*)

Object interaction without a prescribed order. (*)

Writing algorithms.

Correct Correct

2. An object may interact with another object by invoking methods.


Mark for Review
(1) Points

True (*)

False

Correct Correct

3. 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. Mark for Review
(1) Points

True (*)

False

Correct Correct

4. A software feature may allow the user to perform a specific task.


Mark for Review
(1) Points

True (*)

False

Correct Correct

5. During the Design phase of software development, the programmer


implements features gathered during the Requirement phase. Mark for Review
(1) Points

True

False (*)

Correct Correct
6. During the Testing phase of software development, which of the following are
the tasks undertaken by the programmer? Mark for Review
(1) Points

(Choose all correct answers)

Listing required features.

Finding the bugs. (*)

Fixing the bugs. (*)

Planning the order to implement features.

Correct Correct

7. A Java program can be written in the single line. Mark for


Review
(1) Points

True (*)

False
Incorrect Incorrect. Refer to Section 2 Lesson 2.

8. Which two are the correct syntax for adding comments? Mark for
Review
(1) Points

(Choose all correct answers)

Start with two slashes (//). End when the line ends. (*)

Start with two slashes (//). End with two slashes (//).

Start with a slash- star (/*). End with slash-star (/*).

Start with two slashes and a star (//*). End with a star-slash (*/).

Start with a slash-star (/*). End with a star-slash (*/). (*)

Correct Correct

9. Code within curly braces is called a �Block of code�. Mark for


Review
(1) Points

True (*)

False

Correct Correct

Section 3
(Answer all questions in this section)

10. char is the primitive textual data type in Java. Mark for
Review
(1) Points

True (*)
False

Correct Correct
11. Which two statements compile? Mark for Review
(1) Points

(Choose all correct answers)

String name = �Java�; (*)

String name = new String ( �Java�);

String name = �J�; (*)

String name = �Java�;

Correct Correct

12. Which is the correct declaration for a char data type? Mark
for Review
(1) Points

char size = �Medium�;

char size = �Medium�;

char size = �M�;

char size = �M�; (*)

Correct Correct

13. What is the output?

public class Welcome {


public static void main(String args[]) {
System.out.println("This is my first program");
int a = 2;
System.out.println("a is" + a);
}
} Mark for Review
(1) Points
This is my first program a is + a

a=2

This is my first program a is 2 (*)

This is my first program

Correct Correct

14. Which two data types are appropriate for their variable? Mark
for Review
(1) Points

(Choose all correct answers)

String firstName = �Alex�; (*)

int averageDollarAmount = 19.95;

boolean age = 20;

double checkingAmount = 1500; (*)

Correct Correct

15. Which two are valid? Mark for Review


(1) Points

(Choose all correct answers)

double doubleVar1, doubleVar2 = 3.1; (*)

double doubleVar1, double doubleVar2 = 3.1;

double doubleVar1; doubleVar2 = 3.1.

double doubleVar1 = 3.1; double doubleVar2 = 3.1; (*)


Correct Correct
16. Which two statements are true about type casting? Mark for Review
(1) Points

(Choose all correct answers)

Type casting cannot be performed on equations.

Type casting retains the size of the value or the original data type.

Type casting changes the type of the value stored. (*)

Type casting lowers the range of possible values. (*)

Correct Correct

17. Which is a valid way to parse a String as an int? Mark for


Review
(1) Points

int intVar1 = Integer.parseInt("100"); (*)

nt intVar1 = (int)"100";

int intVar1 = Integer.parseInt("One Hundred");

int intVar1 = "100";

Correct Correct

18. Which exception occurs because a String cannot be parsed as an


int? Mark for Review
(1) Points

NumberFormatException (*)

ArithmeticException

NullPointerException

ValueNotFoundException
Correct Correct

19. System.in readies Scanner to collect input from the console.


Mark for Review
(1) Points

True (*)

False

Correct Correct

20. The Scanner class accepts input in which form? Mark for Review
(1) Points

Integer

Callables

Tokens (*)

Future

Correct Correct
21. These two code fragments perform the same task.

// Fragment 1
String inputString = JOptionPane.showInputDialog("??");
int input = Integer.parseInt(inputString);
input++;

// Fragment 2
int input = Integer.parseInt(JOptionPane.showInputDialog("??")) + 1; Mark for
Review
(1) Points

True (*)

False
Correct Correct

22. 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);
}
} Mark for Review
(1) Points

Value of age: 20
Value of age: 8
Value of age: 10 (*)

Value of age: 20
Value of age: 28
Value of age: 38

Value of age: 20
Value of age: 208
Value of age: 20810

Value of age: 20
Value of age: 8
Value of age: 9

Correct Correct

23. What is the range of the byte data type? Mark for Review
(1) Points

�27 to 27�1 (*)

�215 to 215�1

�231 to 231�1

�263 to 263�1
Correct Correct

24. This declaration represents a long data type.


long a = 123L; Mark for Review
(1) Points

True (*)

False

Correct Correct

Section 4
(Answer all questions in this section)

25. What is the output?

public static void main(String args[]) {


String greeting = "Java World!";
String w = greeting.replace("a", "A");
System.out.println(w);
} Mark for Review
(1) Points

JavA World!

Java World!

JAva World!

JAvA World! (*)

Correct Correct
26. The indexOf() method returns the index value of a character in the string.
Mark for Review
(1) Points

True (*)

False
Correct Correct

27. The String class must be imported using java.lang.String; Mark


for Review
(1) Points

True

False (*)

Incorrect Incorrect. Refer to Section 4 Lesson 3.

28. The String concat() method concatenates only String data types.
Mark for Review
(1) Points

True (*)

False

Correct Correct

29. The import statement consists of two parts.

import package.className;

One is the package name and the other is the classname. Mark for Review
(1) Points

True (*)

False

Correct Correct

30. Which of the following wild card character is used to import all
the classes in a particular package? Mark for Review
(1) Points

~
!

* (*)

Correct Correct
31. Import statements are placed above the class definition. Mark for Review
(1) Points

True (*)

False

Correct Correct

32. Given the import statement:


import java.awt.font.TextLayout;
which is the package name? Mark for Review
(1) Points

awt.font

java.awt.font (*)

java.awt

java

Correct Correct

33. The Math class methods can be called without creating an instance
of a Math object. Mark for Review
(1) Points

True (*)

False
Correct Correct

34. What is the package name which contains Math class? Mark for
Review
(1) Points

java.net

java.lang (*)

java.awt

java.io

Correct Correct

35. Methods allow all instance of a class to share same behaviors.


Mark for Review
(1) Points

True (*)

False

Correct Correct

36. An argument is a value that's passed during a method call Mark for Review
(1) Points

True (*)

False

Correct Correct

37. Which of the following are the arguments in the following method?

Employee emp = new Employee();


emp.calculateSalary(100000, 3.2, 15); Mark for Review
(1) Points
calculateSalary(100000, 3.2, 15);

emp.calculateSalary(100000, 3.2, 15);

100000, 3.2, 15 (*)

emp

Correct Correct

38. How many arguments does the following method accept?

public void simpleInterest(double principal, int noofYears, double interestRate){


System.out.println(�The interest rate is � +interestRate );
}
Mark for Review
(1) Points

3 (*)

Correct Correct

39. Which class is used to generate random numbers? Mark for Review
(1) Points

Double

Random (*)

Integer

Number
Correct Correct

40. You need to generate random integer values between 0 and 80


(inclusive). Which statement should you use? Mark for Review
(1) Points

nextInt(0-79);

nextInt(80);

nextInt();

nextInt(81); (*)

Correct Correct
36. An argument is a value that's passed during a method call Mark for Review
(1) Points

True (*)

False

Correct Correct

37. Which of the following are the arguments in the following method?

Employee emp = new Employee();


emp.calculateSalary(100000, 3.2, 15); Mark for Review
(1) Points

calculateSalary(100000, 3.2, 15);

emp.calculateSalary(100000, 3.2, 15);

100000, 3.2, 15 (*)

emp

Correct Correct
38. How many arguments does the following method accept?

public void simpleInterest(double principal, int noofYears, double interestRate){


System.out.println(�The interest rate is � +interestRate );
}
Mark for Review
(1) Points

3 (*)

Correct Correct

39. Which class is used to generate random numbers? Mark for Review
(1) Points

Double

Random (*)

Integer

Number

Correct Correct

40. You need to generate random integer values between 0 and 80


(inclusive). Which statement should you use? Mark for Review
(1) Points

nextInt(0-79);

nextInt(80);

nextInt();
nextInt(81); (*)

Correct Correct
41. 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; Mark for Review
(1) Points

True (*)

False

Correct Correct

Section 5
(Answer all questions in this section)

42. In the AND (&&) test, if the first expression on the left hand
side is false, then there is no need to evaluate the second statement. Mark for
Review
(1) Points

True (*)

False

Correct Correct

43. In Java, an if statement can be nested inside another if


statement. Mark for Review
(1) Points

True (*)

False

Correct Correct
44. An employee is eligible for a bonus based on certain criteria.
Under what conditions does �Eligible for a bonus� print?

int rating;
int experience;
if (rating > 1 && experience == 5) {
System.out.println (�Eligible for a bonus�);
} Mark for Review
(1) Points

Less than 5 experience and 1 rating.

5 experience and 1 rating

5 experience and 2 or more rating (*)

5 rating and 1 experience

Correct Correct

45. The equal sign (=) is used to make an assignment, whereas the ==
sign merely makes a comparison and returns a boolean. Mark for Review
(1) Points

True (*)

False

Correct Correct

46. A String comparison with == compares the Strings� locations in memory and not
the content of the String. Mark for Review
(1) Points

True (*)

False

Correct Correct

47. What is the output?

public static void main(String[] args) {


int age = 43;
if (age == 43){
System.out.print("Bob is 43 ");
}
if (age == 50){
System.out.print("Bob is 50 ");
}
} Mark for Review
(1) Points

Bob is 43 Bob is 50

Bob is 50

No output

Bob is 43 (*)

Correct Correct

48. Which are used in a boolean expression? Mark for Review


(1) Points

(Choose all correct answers)

Variables (*)

Loops

Operators (*)

Errors

Incorrect Incorrect. Refer to Section 5 Lesson 1.

49. A break statement causes control to transfer to the end of the


switch statement. Mark for Review
(1) Points

True (*)

False
Correct Correct

50. Which two of the following data types can be used in a switch
statement? Mark for Review
(1) Points

(Choose all correct answers)

boolean

String (*)

float

int (*)

Correct Correct

Vous aimerez peut-être aussi