JNS Ca Prelim 1 Paper
JNS Ca Prelim 1 Paper
JNS Ca Prelim 1 Paper
SECTION A
(Attempt all questions from this Section.)
Question-1 Choose the correct answer and write the correct option. [20]
1
(iv) Which of these operators is used to allocate memory to array variable in Java?
a. alloc
b. malloc
c. new
d. new malloc
(viii) Which of the given operators can be used to concatenate two or more String objects?
a. +
b. +=
c. &
d. ||
(ix) What will be the value stored in the variable ‘c’ after the following statement is
executed?
char c = “DECODING”.charAt(2);
a. C
b. E
c. D
d. C
2
a. java.lang
b. java.awt
c. java.string
d. java.applet
}
}
a. 1152
b. 11511
c. 1105110
d. 18
(xiv) Automatic conversion of primitive data into an object of wrapper class is called
_______________.
a. autoboxing
b. explicit conversion
c. shifting
d. wrapping
(xv) Which of the following functions is used to remove leading and trailing white spaces
from the string?
a. trail()
b. truncate()
c. slice()
d. trim()
3
(xvii) Which of the following is not a part of looping construct?
a. for
b. break
c. continue
d. close
(xviii) Which of the following statements will terminate the premature execution of a
program?
a. break
b. System.exit(0)
c. stop
d. end
(xix) What value will be stored in the variable p after executing the following code?
double a = -6.35;
double p = Math.abs(Math.ceil(a));
a. 6.5
b. 6.0
c. 6.35
d. -6.0
Question-2
i. What will be the output of the following code? [2]
class try
{
public static void main(String args[])
{
int y = 10;
int z=(++y * (y++ - 5));
System.out.println(y + ", " + z );
}
}
4
ii. What will be the output of the following code? [2]
class Main
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}
iii. How many times will the following loop execute? What value will be value stored in y [2]
?
int x = 2, y = 50;
do
{
++x;
y- = x++;
} while(x <= 10);
iv. Rewrite the following program segment using if-else construct. [2]
String grade=(mark>=90) ? “A” : (mark>=80) ? “B” : “C”.
5
vi. Write function prototypes for the following: [2]
a. A method InChar which takes a string argument st and a character argument
ch and returns an integer value.
b. A method check which receives a character argument ch and an integer
argument n and returns true or false.
vii. What is the difference between isUpperCase() and toUpperCase() method? [2]
6
SECTION B
Write a main() method and create 2 objects to calculate tax for 2 teachers and call the
above methods accordingly.
7
Question-4 Write a program to accept the year of graduation from the user as an integer value. [15]
Using the binary search technique on the sorted array Gy[] given below, output the
message “Record Exists ” with its position - if the value is located in the array. If not,
output the message “Record does not exist”.
Gy[0] Gy[1] Gy[2] Gy[3] Gy[4] Gy[5] Gy[6] Gy[7] Gy[8] Gy[9]
1990 1992 1994 1998 1999 2002 2004 2008 2010 2014
Question-5 Write a program in Java to input a number and check whether it is a Unique number [15]
or not. [A number is said to be unique , if the digits in it are not repeated. for example,
12345 is a unique number. 123445 is not a unique number.].
(ii) void check(String s1) – to display only vowels from string s1 after converting it to
to lower case.
Sample Input : Enter String : s1 = “computer”
Sample Output: The vowels in the string are : o u e
(iii) char check(String st, int idx) - to display the character at the specified index (idx)
in a string
Sample Input : Enter String : st = “Technology”
Enter the index : 3
Sample Output: The character at index 3 is : h
8
Question-7 Special words are those words which start and end with the same letter. [15]
Examples: EXISTENCE COMIC WINDOW .
Palindrome words are those words which read the same from left to right and vice
versa.
Examples: MALAYALAM MADAM LEVEL ROTATOR CIVIC
All palindromes are special words, but all special words are not palindromes. Write a
program to accept six words in an array arrWord[] . Check and print the palindrome
and special words and only special word from the array an array and also print their
frequency.
Sample Input :
COMIC ICICI MOM MALYALAM EXISTENCE DAD
Sample Output :
Palindrome and Special Words are : ICICI, MOM, MALYALAM,DAD
Frequency of Palindrome and Special words : 4
Special Words are : COMIC, EXISTENCE
Frequency of Special Words : 2
Question-8 Write a program to input 10 numbers into an integer type array and arrange the [15]
numbers in descending order using Bubble Sort technique.
_____________________________________________________________________