1.
Which one of the following is NOT a correct
variable name?
A.2bad
B.It declares values to be a reference to an array
object, but initializes it to null.
C.It declares values to be a reference to an array
B.Zero
object which does not yet exist,
C.TheLastValueButOne
but will contain 10 zeros when it does.
D.Year2000
2. 47. Which of the following statements does NOT
define a String array called myArray that contains
five elements?
A.String[] myArray = new String[5];
D.It declares values to be a reference to an array
which contains 10 references to int variables.
7. What is the name for an application that changes
a human-readable programming language into a
machine-readable language?
B.String [] myArray = new String[5];
A.Compiler
C.String []myArray = new String[5];
B.Converter
D.String[5] myArray = new String();
C.Encoder
3. What do you call a group of statements contained
D.Interpreter
with an opening bracket and a closing bracket?
8. What is the output of the following:
A.A block statement
= 0, b = 10;
B.Groupware
System.out.println("a= " + a + " b= " + b );
C.Bracketed statements
A.A= 9 b=11
D.Not in the list provided
B.A= 10 b= 9
4. Which of the answers does the same thing as the
C.A= 9 b=9
following: value += sum++ ;
A.Value = value + sum;
a = --b ;
D.A= 0 b=9
9. What types of information are arrays best suited
sum = sum + 1;
for?
B.Sum = sum + 1;
A.Lists
value = value + sum;
int a
B.Pairs of related information
C.Value = value + sum;
C.Trivia
D.Value = value + ++sum;
10. Another word for "looping" is:
5. 46. Consider the following code int number[] = new
A.Recapitulation
int[5]; After execution of this statement, which of
B.Tintinabulation
the following are true? (A) number[0] is undefined
C.Iteration
(B) number[5] is undefined (C) number[4] is null
D.Reiteration
(D) number[2] is 0 (E) number.length() is 5
11. What is the output of the following code
A.B, D & E
fragment? for ( int j = 10; j > 5; j-- ) {
B.A & E
System.out.print( j + " " ); } System.out.println( );
C.C & E
A.10 11 12 13 14 15
D.E
B.9 8 7 6 5 4 3 2 1 0
6. What does the following statement do? int[]
C.10 9 8 7 6 5
values = new int[10] ;
A.It declares values to be a reference to an array
D.10 9 8 7 6
12. What is the result of evaluating the following
object and constructs an array object containing 10
integers which are initialized to zero.
expression?
A.8
(1/2 + 3.5) * 2.0
B.7.0
A.Names[0] = "Hello" ;
C.6.0
B.Names[10] = "Hello" ;
D.None of the above
C.Names[9] = "Hello" ;
13. What must the test be so that the following
D.String[ names.length-1 ] = "Hello" ;
fragment prints out the integers -5 through and
18. What does this code print on the monitor?
including 5? for ( int j = -5; ________ ; j++ ){
int count = 7;
System.out.print( j + " " ); }
count >= 4 ) {
A.J<5
System.out.print( count + " "
); count = count - 1;
B.J<=5
A.1 2 3 4 5 6 7
C.J>5
B.7 6 5 4
D.J==5
C.6 5 4 3
14. Examine the following code fragment:
1;
while (
int j =
while ( j < 10 ) {
System.out.println( j + " " );
} System.out.println( );
D.7 6 5 4 3
19. What is the meaning of variable++ ?
j = j + j%3;
} What is output?
A.1 4 7
A.Add one to the variable.
B.Add one to the variable after its current value has
been used.
B.1 4 7 10
C.Add one to the variable before using its value.
C.1 2 5 8
D.Double the value in the variable.
D.1 2 4 5 7 8
20. Fill in the blank so that the following adds up the
15. 49. What are the legal indexes for the array ar,
odd numbers from 1 to 99 int sum = 0; for ( int
given the following declaration: int[] ar = {2, 4, 6,
num = 1; num <=99; __________ ) sum +=
8}
num;
System.out.println( sum );
A.0, 1, 2, 3
A.J++
B.1, 2, 3, 4
B.Num+2
C.2, 4, 6, 8
C.Num+=2
D.0, 2, 4. 6
D.Num--
16. Pick the for loop which duplicates this while loop:
21. What must the test be so that the following
int x = 0; while ( x < 500 ) { System.out.println( x
fragment prints out the integers from 5 through
); x = x + 5; }
15? for ( int j = 5; ________ ; j++ ){
A.for ( int x = 0; x < 500; x+=5 )
System.out.println( x );
B.For ( float x = 0.0; x < 500.0; x += 5.0 )
System.out.println( x );
C.For ( int x = 500; x >= 0; x-=5 )
System.out.println( x );
D.for ( int x = 500; x <= 0; x-=5 )
System.out.println( x );
System.out.print( j + " " ); }System.out.println( );
A.J<15
B.J<=16
C.j<16
D.J==15
22. What is the output of the following code
fragment? for ( int j = 5; j > -5; j-- )
System.out.print( j + " " );
17. Given the declaration String[] names = new
String[10] ; Which of the following statements
A.-5 -4 -3 -2 -1 0
puts a reference to the String "Hello" in the last
B.5 4 3 2 1 0
slot of the array?
C.5 4 3 2 1 0 -1 -2 -3 -4 -5
System.out.println( );
D.5 4 3 2 1 0 -1 -2 -3 -4
D.13
23. The && operator works with which data types?
5. It terminates every line of code in Java.
A.Int
A.}
B.Long
B.)
C.Double
C.;
D.Boolean
D..
24. Does every Java variable use a data type?
6. Which of the following is the data type used for a
A.No---only numeric variables use data types.
single character?
B.No---data types are optional.
A.Byte
C.Yes---all variables are of the same data type.
B.Short
D.Yes---each variable must be declared along with its
C.Long
data type.
25. What kind of programming language is Java?
A.An object-oriented programming language
B.An array programming language
C.A logic programming language
D.A database programming language
Question Excerpt
D.Char
7. It is the characteristics of Java which ensures that
a program can go only where it is designed to go
and eliminates the possibility of altering system
data unintentionally.
A.Java is simple.
B.Java is secure.
C.Java is free.
1. Which of the following is not a unary operator?
D.Java is portable.
A.Negation
8. It is the rules of a programming language.
B.Decrement
C.Bitwise complement
D.Assignment
2. Using the declaration below, what will be the final
element of the array? int [ ] grades = new int[35];
A.Grades[0]
B.Grades[34]
C.Grades[35]
D.Impossible to tell
3. Which of the following is an invalid variable
declaration in Java?
A.Int NumberOfStudents = 250;
B.Double Salary =0.0;
C.String NAME =
D.Char CivilStatus =
4. If A=10, then after B=++A, the value of B is
_______.
A.10
B.11
C.12
A.Format
B.Logic
C.Object
D.Syntax
9. Which of the following is not a Java keyword?
A.Default
B.For
C.Volatile
D.Of
10. Which of the following is not a primitive data
type?
A.Byte
B.String
C.Char
D.Long
11. It defines the common variables and methods of
a set of objects.
A.Objects
B.Class
C.Function
D.Method
A.8 bits
12. It is the Java keyword that creates inheritance.
B.12 bits
A.Enlarge
C.16 bits
B.Extends
D.32 bits
C.Inherits
20. Which symbol is used to denote a multi-line
comment?
D.Inheritance
13. Which of the following is an invalid first character
of an identifier?
A./ /
B./* */
A.__
C.{ }
B.$
D.< >
C.A
Question Excerpt
D.8
1. Select C if the given statement is CORRECT,
14. It is the process of removing errors found in the
otherwise select I.
program.
public static main void (String
args[]){
A.Editing
A.C
B.Debugging
B.I
C.Compiling
2. Select C if the given statement is CORRECT,
D.Running
otherwise select I.
char next_line="\n");
15. It is the length of the data type short.
A.C
A.8 bits
B.I
B.16 bits
3. Select C if the given statement is CORRECT,
C.32 bits
otherwise select I.
D.64 bits
A.C
16. It is the command used to compile Java program
B.I
in the command prompt.
int
4. Select V if the identifier below is VALID,
A.Ja
otherwise select I.
Strong
B.Jav
A.V
C.Java
B.I
D.Javac
5. Select V if the identifier below is VALID,
otherwise select I.
17. It is the code/s inside a pair of curly braces.
char
A.Block
A.V
B.Brick
B.I
C.Function
6. Select C if the given statement is CORRECT,
otherwise select I.
D.Method
18. It is a form of Java program that runs locally on
the command line.
A.Applets
Public class SECOND {
A.C
B.I
7. Select V if the identifier below is VALID,
otherwise select I.
B.Application
C.Midlets
A.V
D.Servlets
B.I
19. It is the length of the data type float.
8. Select V if the identifier below is VALID,
otherwise select I.
==counter
otherwise select I.
cake
A.V
A.V
B.I
B.I
9. Select C if the given statement is CORRECT,
19. Select V if the identifier below is VALID,
otherwise select I.
int number1=23.45;
otherwise select I.
large
A.C
A.V
B.I
B.I
10. Select V if the identifier below is VALID,
20. Select V if the identifier below is VALID,
otherwise select I.
Byte
otherwise select I.
*pointer
A.V
A.V
B.I
B.I
11. Select C if the given statement is CORRECT,
21. Select V if the identifier below is VALID,
otherwise select I.
Short classes=19;
otherwise select I.
Default
A.C
A.V
B.I
B.I
12. Select C if the given statement is CORRECT,
22. Select C if the given statement is CORRECT,
otherwise select I.
public static void main
otherwise select I.
Boolean a;
A.C
(string [] args) {
A.C
B.I
B.I
23. Select C if the given statement is CORRECT,
13. Select C if the given statement is CORRECT,
otherwise select I.
otherwise select I.
float a, int b;
System.out.pritnln("Java
Programming is COOL!");
A.C
A.C
B.I
B.I
14. Select C if the given statement is CORRECT,
24. Select C if the given statement is CORRECT,
otherwise select I.
double 56;
otherwise select I.
char gender="m";
A.C
A.C
B.I
B.I
15. Select C if the given statement is CORRECT,
25. Select V if the identifier below is VALID,
otherwise select I.
System.in.print('number');
otherwise select I.
short
A.C
A.V
B.I
B.I
16. Select V if the identifier below is VALID,
26. Select V if the identifier below is VALID,
otherwise select I.
2nd_num
otherwise select I.
int
A.V
A.V
B.I
B.I
17. Select V if the identifier below is VALID,
27. Select V if the identifier below is VALID,
otherwise select I.
_Public
otherwise select I.
Main
A.V
A.V
B.I
B.I
18. Select V if the identifier below is VALID,
28. Select C if the given statement is CORRECT,
otherwise select I.
System.out.println('Welcome to Java');
6. int a=5,b=2,c;
A.C
if(a>b || a!=b)
B.I
c = ++a + --b;
29. Select V if the identifier below is VALID,
System.out.println(c+" "+a+" "+b);
otherwise select I.
initial
7. Write the output of the following code
A.V
snippet
B.I
int i = 1;
30. Select C if the given statement is CORRECT,
otherwise select I.
/* This is a single line
comment
A.I
while(i++<=1)
{
i++;
System.out.print(i+" ");
B.C
}
1.
What is the value of z if z=++x*y---y, where
System.out.print(i);
int x=22, y=29,z=0 ?
8. Write the output
Ans :- a) 419 b) 667 c) 619 d) 639
class name{
public void roll(){
int a=26;char b='C';
2. What will be the output of the following
int ac=a+b;
code ?
System.out.println(ac+b+'a');
}
float x=7.87F;
System.out.println(Math.ceil(x));
System.out.println(Math.floor(x));
9. Evaluate the following expressions :
(when a=4, b=2, c=3)
a) a%2+++b*c++;
3. String s="Softech Tutorial Home";
int p=s.indexOf('o');
System.out.println(p);
System.out.println(p+s);
4. String st="SOFTECH";
System.out.println(st.indexOf(st.charAt(3)));
b) b-----c+++a;
c) a+++b+++c++;
d) ++a-b+++c++;
e) ++c+b+a--;
10. Write the output :
int k=1, j=0;
while(k<=10)
5. int a=0;
if(a>0 && a<20)
for(j=k;j<5;j++)
a++;
else
a--;
System.out.println(a);
System.out.print(j+" ");
System.out.println();
k++;
}
11. Write the output of the following code
System.out.println(c);
snippet
int a=94,c=6;
16. System.out.println
double x=3,b=9.0;
(Math.max(Math.min(11,45),5);
String s="Enjoy Working Hard";
if(((a+x)<105) && (++a - c*x<=45))
{
System.out.println(Math.pow(c,x));
System.out.println(a*c+b);
}
else if((++a*2)>(x+a*3)){
System.out.println((4*c++)%6);
System.out.println((char)(a+c));}
System.out.println("a : "+a+" and position is
"+s.lastIndexOf('o'));
12. What will the following function return :
a) Math.ceil(-17.99)
b) Math.floor(9.99)
c) Math.rint(39.5)
d) Math.max(-19,-27)
e) Math.round(-33.53)
13. Write the output :
int i;
for(i=0; i<50; ++i){
if(i==6)
break;
System.out.println(i);
}
14. Write the output of the following code :
int x=1,y=2;
do {
x * = y;
}while(++y<5);
System.out.println(x);
15. Write the output of the following code :
int a=2, b=5;
int c= a++ + --b+ ++a - b++;