Tuesday, June 22, 2021

JAVA Programming || Objective Questions Practice Set!

 




JAVA Programming || Objective Questions Brainware Set!

 

1. What is the range of data type short in Java?

a) -128 to 127

b) -32768 to 32767

c) -2147483648 to 2147483647

d) None of the mentioned

 

2. What is the range of data type byte in Java?

a) -128 to 127

b) -32768 to 32767

c) -2147483648 to 2147483647

d) None of the mentioned

 

3. Which of the following are legal lines of Java code?

1. int w = (int)888.8;

2. byte x = (byte)100L;

3. long y = (byte)100;

4. byte z = (byte)100L;

a) 1 and 2

b) 2 and 3

c) 3 and 4

d) All statements are correct.

 

 

 

 

 

 

4. An expression involving byte, int, and literal numbers is promoted to which of these?

a) int

b) long

c) byte

d) float

 

 

5. Which of these literals can be contained in a data type float variable?

a) 1.7e-308

b) 3.4e-038

c) 1.7e+308

d) 3.4e-050

 

6. Which data type value is returned by all transcendental math functions?

a) int

b) float

c) double

d) long

 

7. What is the output of this program?

1.             class average {

2.                 public static void main(String args[])

3.                 {

4.                     double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};

5.                     double result;

6.                     result = 0;

7.                     for (int i = 0; i < 6; ++i)

8.                         result = result + num[i];

9.                         System.out.print(result/6);

10.      

11.               }

12.           }

a) 16.34

b) 16.566666644

c) 16.46666666666667

d) 16.46666666666666

 

8. What is the output of this program?

1.             class conversion {

2.                 public static void main(String args[])

3.                 {   

4.                      double a = 295.04;

5.                      int  b = 300;

6.                      byte c = (byte) a;

7.                      byte d = (byte) b;

8.                      System.out.println(c + " "  + d);

9.                 }

10.           }

a) 38 43

b) 39 44

c) 295 300

d) 295.04 300

 

9. What is the output of this program?

1.             class increment {

2.                 public static void main(String args[])

3.                 {       

4.                      int g = 3;

5.                      System.out.print(++g * 8);

6.                 }

7.             }

a) 25

b) 24

c) 32

d) 33

 

10. What is the output of this program?

1.             class area {

2.                 public static void main(String args[])

3.                 {   

4.                      double r, pi, a;

5.                      r = 9.8;

6.                      p1 = 3.14;

7.                      a = pi * r * r;

8.                      System.out.println(a);

9.                 }

10.           }

a) 301.5656

b) 301

c) 301.56

d) 301.56560000

 

11. What is the output of relational operators?

a) Integer

b) Boolean

c) Characters

d) Double

 

12. Which of these is returned by greater than, <, and equal to, ==, operator?

a) Integers

b) Floating - point numbers

c) Boolean

d) None of the mentioned

 

13. Which of the following operators can operate on a boolean variable?

1. &&

2. ==

3. ?:

4. +=

a) 3 & 2

b) 1 & 4

c) 1, 2 & 4

d) 1, 2 & 3

 

14. Which of these operators can skip evaluating right hand operand?

a) !

b) |

c) &

d) &&

 

15. Which of these statement is correct?

a) true and false are numeric values 1 and 0.

b) true and false are numeric values 0 and 1.

c) true is any non zero value and false is 0.

d) true and false are non numeric values.

 

16. What is the output of this program?

1.             class Relational_operator {

2.                 public static void main(String args[])

3.                 {

4.                     int var1 = 5;

5.                     int var2 = 6;

6.                     System.out.print(var1 > var2);

7.                 }

8.             }

a) 1

b) 0

c) true

d) false

 

17. What is the output of this program?

1.             class bool_operator {

2.                 public static void main(String args[])

3.                 {   

4.                      boolean a = true;

5.                      boolean b = !true;

6.                      boolean c = a | b;

7.                         boolean d = a & b;

8.                      boolean e = d ? b : c;

9.                      System.out.println(d + " " + e);

10.               }

11.           }

a) false false

b) true ture

c) true false

d) false true

 

18. What is the output of this program?

1.             class ternary_operator {

2.                 public static void main(String args[])

3.                 {       

4.                      int x = 3;

5.                      int y = ~ x;

6.                      int z;

7.                      z = x > y ? x : y;

8.                      System.out.print(z);

9.                 }

10.           }

a) 0

b) 1

c) 3

d) -4

 

19. What is the output of this program?

1.             class Output {

2.                 public static void main(String args[])

3.                 {   

4.                      int x , y = 1;

5.                      x = 10;

6.                      if (x != 10 && x / 0 == 0)

7.                          System.out.println(y);

8.                      else

9.                          System.out.println(++y);

10.               }

11.           }

a) 1

b) 2

c) Runtime error owing to division by zero in if condition.

d) Unpredictable behavior of program.

 

20. What is the output of this program?

1.             class Output {

2.                 public static void main(String args[])

3.                 {   

4.                      boolean a = true;

5.                      boolean b = false;

6.                      boolean c = a ^ b;

7.                      System.out.println(!b);

8.                 }

9.             }

a) 0

b) 1

c) false

d) true

21. Which of these selection statements test only for equality?

a) if

b) switch

c) Both a & b

d) None of the mentioned

 

22. Which of these are selection statements in Java?

a) if()

b) for()

c) continue

d) break

 

 

23. Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a) do-while

b) while

c) for

d) None of the mentioned

 

24. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

a) break

b) return

c) exit

d) continue

 

25. Which of these statements is correct?

a) switch statement is more efficient than a set of nested ifs.

b) two case constants in the same switch can have identical values.

c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression.

d) it is possible to create a nested switch statements.

 

26. What is the default data type of a decimal number in Java?

a. int

b. float

c. double

d. long

 

27 JAVA variable cannot begin with.             

a.         An alphabet

b.         A number

c.         A special symbol other that underscore

d.         Both B and C

28. In JAVA, Which Class __________ cannot inherits?

a.         super class

b.         abstract class

c.         sub class

d.         final class

29. Which of the following statements about the Java language is true?

a.         Java supports only Procedural approach towards programming

b.         Both Procedural and Object Oriented Programming are supported in Java

c.         Java supports only Object Oriented Programming approach

d.         None of the Above

30. Which of the following is logical operator?

a.         &&

b.         ++

c.         !

d.         ~

31.How many times the loop will execute for the given program.

int k=5;

do

{

 System.out.println(“JAVA IS PURE OOPs”);

}

while(k>=1);

 

a.         1 times                                    c. infinite times                       

b.         5 times                                    d. None of these.

 

32. JVM stands for

a. Java Verified Machine

b. Java Virtual Machine

c. Java Very large Machine

d. Java Very small Machine

 

33. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

a) break

b) return

c) exit

d) continue

34. Which of this statement is correct?

a) true and false are numeric values 1 and 0.

b) true and false are numeric values 0 and 1.

c) true is any non zero value and false is 0.

d) true and false are non numeric values.

35) What are the major components of the JDBC?

a.         DriverManager, Driver, Connection, Statement, and ResultSet

b.         DriverManager, Driver, Connection, and Statement

c.         DriverManager, Statement, and ResultSet

d.         DriverManager, Connection, Statement, and ResultSet

36) Select the packages in which JDBC classes are defined?

a.         jdbc and javax.jdbc

b.         rdb and javax.rdb

c.         jdbc and java.jdbc.sql

d.         sql and javax.sql

37) Which of the following method is used to perform DML statements in JDBC?

a.         executeResult()

b.         executeQuery()

c.         executeUpdate()

d.         execute()

38) Which methods are required to load a database driver in JDBC?

a.         getConnection()

b.         registerDriver()

c.         forName()

d.         Both b and c

39) Parameterized queries can be executed by?

a.         ParameterizedStatement

b.         PreparedStatement

c.         CallableStatement and Parameterized Statement

d.         All kinds of Statements

40) Which of the following is not a valid statement in JDBC?

a.         Statement

b.         PreparedStatement

c.         QueryStatement

d.         CallableStatement

41) What should be the correct order to close the database resource?What should be the correct order to close the database resource?

a.         Connection, Statements, and then ResultSet

b.         ResultSet, Connection, and then Statements

c.         Statements, ResultSet, and then Connection

d.         ResultSet, Statements, and then Connection

 

42) JDBC-ODBC driver is also known as?

a.         Type 4

b.         Type 3

c.         Type 1

d.         Type 2

 

43) Identify the DSN in the following statement:

DriverManager.getConnection("jdbc:odbc:oradsn", "scott", "tiger") 

a.         jdbc

b.         odbc

c.         scott

d.         oradsn

 

44) JDBC Stands for ____________.:

a.         Java Data Base Connectivity

b.         Java Data Base Connection

c.         Java Data Based Connection

d.         Java DBMS Connectivity

 

45. Which of the following contains both date and time?

a) java.io.date

b) java.sql.date

c) java.util.date

d) java.util.dateTime

 

46. Which of the following is advantage of using JDBC connection pool?

a) Slow performance

b) Using more memory

c) Using less memory

d) Better performance

 

47. Which of the following is used to call stored procedure?

a) Statement

b) PreparedStatement

c) CallableStatment

d) CalledStatement

 

48. Which of the following is advantage of using PreparedStatement in Java?

a) Slow performance

b) Encourages SQL injection

c) Prevents SQL injection

d) More memory usage

 

49. Which method is used to establish connection?

a) getConnection()

b) Class.forName()

c) createStatement()

d) PreparedStatement()

 

50. Which Package used in JDBC Concept?

a. java.utill package

b. java.lang package

c. java.sql package

d. java.io package

 

51.Default Layout Manager of Panel is ______________.                                                               

a.         FlowLayout

b.         BorderLayout

c.         GridLayout

d.         AbsCoordinate

53. Which Tags Supported in JSP.   

a.         scriplet

b.         declaration

c.         expression

d.         all of the above

54. JSP Comment of Server page.               

e.         <!-- Comment -->

f.          <%--Comment--%>

g.         Both a & b

h.         None of these

55. _____________ used to includes a file during the translation phase.

a.         page directive

b.         include directive

c.         taglib directive

d.         all of the above

56.       ____________ is set of JAVA API used for executing SQL Statements.

a.         JSP.

b.         Servlet.

c.         JDBC.

d.         Struts.

 

 

57. Which Exception requiredto handle in JDBC Application?

a.         SQLException

b.         IOException

c.         ArithmeticException

d.         ClassNotFoundException

58. _______________ is server side programming technology that enables creation of dynamic web page for building web based application.

a. JSP.

b. Servlet.

c. JDBC.

d. Struts.

  59. _______________ is Supported Type-4 Driver of JDBC Application.

a.         Native Protocol Pure Java Driver.

b.         Native API Partly Java Driver.

c.         JDBC-ODBC Bridge Driver.

d.         JDBC Net Pure Java Driver.

 

 

60. JSP stands for

a.         Java Secure Page

b.         Java ServerPage

c.Java Smart Page

d.         Java Small Page

61.Which Method of Statement interface used for Executing Select Query.

a. execute

b.executeUpdate

c. executeQuery

d. All of these.

62. JAVA Package for Networking Utilities.

a. java.lang

b. java.sql

c. java.net

d. java.utill

63. Which SQL Statement used for Executing Stored Procedure.

a. Statement

b. PreparedStatement

c. CallableStatement

d. All of these.

  64. _______________ is java programming language class used to extend the capability of server.

a.         JSP.

b.         Servlet.

c.         JDBC.

d.         Struts.

65.__________________ JSP tags contain Java Code.

a.         Declaration

b.         Directive

c.         Scriplet

d.         Expression

66. ___________ is anOpen Source Web Framework that extends Java Servlet API to employ

MVC architecture.

a. JSP

b. Servlet

c. Struts

d. JDBC

67.  Default value of action attributes in form tags.

a.         get

b.         post

c.         both a & b

d.         none of these

68. Non Executable code of JAVA Programming language.

a. Package

b. Comment

c. Array

d. Variable

69. _____ is the ability of an Java application to perform multiple tasks at the same time?

a.         Multiprogramming

b.         Multithreading

c.         Multiprocessing

d.         Multitasking

70. Which of the following is used to redirect the response from a servlet to a JSP page?

a.response.sendRedirect()

b.request.sendRedirect()

c.request.forward()

d.response.forward()

17. What is the default data type of a decimal number in Java?

a. int

b. float

c. double

d.long

72.       Character variable can store _____ at a time.                                                                      

e.         1 character

f.          8 character

g.         254 character

h.         None of above

73. In JAVA __________ can not inherits.    

e.         super class

f.          abstract class

g.         sub class

h.         final class

74. JAVA variable cannot begin with.            

i.          An alphabet

j.          A number

k.         A special symbol other that underscore

l.          Both B and C

 

75. In JAVA__________ cannot instantiated.

e.         super class

f.          abstract class

g.         sub class

h.         final class

76.       Which of the following is false in JAVA         

e.         Keywords cannot be used as variable names.

f.          A variable name begins withDigit.

g.         Variable names do not contain a blank space.

h.         Capital letters can be used in variable names.

 

 

77. Which of the following statements about the Java language is true?

a.         Java supports only Procedural approach towards programming

b.         Both Procedural and Object Oriented Programming are supported in Java

c.         Java supports only Object Oriented Programming approach

d.         None of the Above

 

78. Which of the following is not logical operator?

e.         &&

f.          ++

g.         !

h.         ||

 

 

79.How many times the loop will execute for the given program.

int k=5;

do

{

System.out.println(“JAVA IS PURE OOPs”);

}

while(k>=1);

 

c.         1 times                                    c. infinite times                       

d.         5 times                                    d. None of these.

 

80. JVM stands for

a.         Java Verified Machine

b.         Java Virtual Machine

c.         Java Very large Machine

d.         Java Very small Machine

 

81.__________Generated after the compile of JAVA program.

a. JVM

b.bytecode

c. class file

d. both b & c.

82. Output of given JAVA program:-

main()

{

 int a=4,y;

y=a++;

System.out.print(“\ny = ”+y);

System.out.print(“a = ”+a)

}

a.         y=5 a=5          

b.         y=4 a=5          

c.         y=5      a=4     

d.         None of these

 

83. Unary operator of JAVA Programming language.

a.         ++

b.         --

c.        

d.         All of the above.

 

84. JAVA Package for file handling.

a. lang

b. io

c. fstream.h

d. utill

 

85. JRE stands for

a.         Java Real Environment

b.         Java Rapid Enterprise

c.         Java RuntimeEnvironment

d.         None of the above

 

86.Default section of class in JAVA is ____________.

e.         public

f.          private

g.         protected

h.         none of these

87. ___________ is a name given to a variable, class or method

a. Constant

b. Reference

c. Identifier

d. Modifier

88.  Which variable cannot reinitialize.

e.         static variable

f.          abstract variable

g.         local variable

h.         final variable

89. Non Executable code of JAVA language.

a. Package

b. Comment

c. Array

d. Variable

90. Which ofthe following is exit controlled loop?

e.         For

f.          While

g.         Do while

h.         None of these

91.What is the default data type of a decimal number in Java?

a. int

b. float

c. double

d. long

92.       Character variable can store _____ at a time.                                                                      

i.          1 character

j.          8 character

k.         254 character

l.          None of above

93. In JAVA __________ can not inherits.    

e.         super class

f.          abstract class

g.         sub class

h.         final class

94. JAVA variable cannot begin with.            

m.        An alphabet

n.         A number

o.         A special symbol other that underscore

p.         Both B and C

95.  In JAVA __________ cannot instantiated.

a.         super class

b.         abstract class

c.         sub class

d.         final class

96.       Which of the following is false in JAVA         

i.          Keywords cannot be used as variable names.

j.          A variable name begins with Digit.

k.         Variable names do not contain a blank space.

l.          Capital letters can be used in variable names.

97. Which of the following statements about the Java language is true?

a.         Java supports only Procedural approach towards programming

b.         Both Procedural and Object Oriented Programming are supported in Java

c.         Java supports only Object Oriented Programming approach

d.         None of the Above

98. Which of the following is not logical operator?

i.          &&

j.          ++

k.         !

l.          ||

99.How many times the loop will execute for the given program.

int k=5;

do

{

 System.out.println(“JAVA IS PURE OOPs”);

}

while(k>=1);

 

e.         1 times                                    c. infinite times                       

f.          5 times                                    d. None of these.

100. JVM stands for

a. Java Verified Machine

b. Java Virtual Machine

c. Java Very large Machine

d. Java Very small Machine

 

101. What is the output of this program?

13.           class average {

14.               public static void main(String args[])

15.               {

16.                   double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};

17.                   double result;

18.                   result = 0;

19.                   for (int i = 0; i < 6; ++i)

20.                       result = result + num[i];

21.                       System.out.print(result/6);

22.      

23.               }

24.           }

a) 16.34

b) 16.566666644

c) 16.46666666666667

d) 16.46666666666666

 

 

 

102. What is the output of this program?

11.           class conversion {

12.               public static void main(String args[])

13.               {   

14.                    double a = 295.04;

15.                    int  b = 300;

16.                    byte c = (byte) a;

17.                    byte d = (byte) b;

18.                    System.out.println(c + " "  + d);

19.               }

20.           }

a) 38 43

b) 39 44

c) 295 300

d) 295.04 300

 

103. What is the output of this program?

8.             class increment {

9.                 public static void main(String args[])

10.               {       

11.                    int g = 3;

12.                    System.out.print(++g * 8);

13.               }

14.           }

a) 25

b) 24

c) 32

d) 33

 

104. What is the output of this program?

11.           class area {

12.               public static void main(String args[])

13.               {   

14.                    double r, pi, a;

15.                    r = 9.8;

16.                    p1 = 3.14;

17.                    a = pi * r * r;

18.                    System.out.println(a);

19.               }

20.           }

a) 301.5656

b) 301

c) 301.56

d) 301.56560000

105. What is the output of relational operators?

a) Integer

b) Boolean

c) Characters

d) Double

106. Which of these is returned by greater than, <, and equal to, ==, operator?

a) Integers

b) Floating - point numbers

c) Boolean

d) None of the mentioned

 107. Which of this statement is correct?

a) true and false are numeric values 1 and 0.

b) true and false are numeric values 0 and 1.

c) true is any non zero value and false is 0.

d) true and false are non numeric values.

 108. What is the output of this program?

11.           class ternary_operator {

12.               public static void main(String args[])

13.               {       

14.                    int x = 3;

15.                    int y = ~ x;

16.                    int z;

17.                    z = x > y ? x : y;

18.                    System.out.print(z);

19.               }

20.           }

a) 0

b) 1

c) 3

d) -4

 109. What is the output of this program?

12.           class Output {

13.               public static void main(String args[])

14.               {   

15.                    int x , y = 1;

16.                    x = 10;

17.                    if (x != 10 && x / 0 == 0)

18.                        System.out.println(y);

19.                    else

20.                        System.out.println(++y);

21.               }

22.           }

a) 1

b) 2

c) Runtime error owing to division by zero in if condition.

d) Unpredictable behavior of program.

 120. What is the output of this program?

10.           class Output {

11.               public static void main(String args[])

12.               {   

13.                    boolean a = true;

14.                    boolean b = false;

15.                    boolean c = a ^ b;

16.                    System.out.println(!b);

17.               }

18.           }

a) 0

b) 1

c) false

d) true

121. Which of these selection statements test only for equality?

a) if

b) switch

c) Both a & b

d) None of the mentioned

 122. Which of these are selection statements in Java?

a) if()

b) for()

c) continue

d) break

 123. Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a) do-while

b) while

c) for

d) None of the mentioned

 124. Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

a) break

b) return

c) exit

d) continue

 125. Which of these statements is correct?

a) switch statement is more efficient than a set of nested ifs.

b) two case constants in the same switch can have identical values.

c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression.

d) it is possible to create a nested switch statements.

 

 

No comments:

Post a Comment

CMS - 2024 || JAC INTERMEDIATE EXAMINATION - 2024 || 12th COMPUTER SCIENCE!

  Part-A Multiple Choice Questions 1) Who is the developer C++? a) Von Neumann b) Dennis M. Ritchie c) Charles Babbage d) Bjarne Stroustrup ...