0% found this document useful (0 votes)
40 views14 pages

Java Technologies Exam Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views14 pages

Java Technologies Exam Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

CENTURION UNIVERSITY OF TECHNOLOGY & MANAGEMENT

ANDHRA PRADESH

EXAMINATION CELL

SUBJECT NAME: (NAME IN FULL): JAVA TECHNOLOGIES

SUBJECT CODE: CUTM1031

MODULE NO: 4
S.
NO
1 String in Java is a?
A class YES
B object
C variable
D character array
2 Which of these method of String class is used
to obtain character at specified index?
A char()
B Charat()
C charat()
D charAt() YES
3 Which of these keywords is used to refer to
member of base class from a subclass?
A upper
B super YES
C this
D none of the mentioned
4 Which defines a method called nextElement
that is used to get the next element in a data
structure that contains multiple elements?
A Bitset
B Vector
C Stack
D Enumeration YES
5 Consider the following two statements
int x = 25;
Integer y = new Integer(33);
What is the difference between these two
statements?
A Primitive data types
B primitive data type and an object of a wrapper YES
class
C Wrapper class
D None of the above
6 Where does the primitive data type values be
stored?
A Heap Memory
B Stack Memory YES
C Both A & B
D None of the above
7 What package is a part of the wrapper class
which is imported by default into all Java
programs?
A java.lang YES
B java.aw
C java.io
D java.util
8 Which of these method of String class can be
used to test to strings for equality?
A isequal()
B isequals()
C equal()
D equals() YES
9 Which of the following statements are
incorrect?
A String is a class
B Strings in java are mutable YES
C Every string is an object of class String
D Java defines a peer class of String, called
StringBuffer, which allows string to be altered
10 What will be the output of the following Java
program?
class string_demo
{
public static void main(String args[])
{
String obj = "I" + "like" + "Java";
System.out.println(obj);
}
}
A I
B like
C Java
D IlikeJava
11 What will be the output of the following Java
program?

class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}
A I YES
B L
C K
D E
12 What will be the output of the following Java
program?

class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.length());
}
}
A 9
B 10
C 11 YES
D 12
13 What will be the output of the following Java
program?

class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
A hello hello
B world world
C hello world YES
D world hello
14 What will be the output of the following Java
program?

class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " "
+ obj.equals(obj2));
}
}
A false false
B true true
C true false
D false true YES
15 Where an object of a class get stored?
A Heap YES
B Stack
C Disk
D File
16 Java uses two stage system for program
execution. They are
A Compiler and instruction
B Compiler and interpreter YES
C Copy and compiler
D None
17 Garbage collection in Java is
A Unused package in a program automatically
gets deleted.
B Memory occupied by objects with no YES
reference is automatically reclaimed for
deletion.
C Java deletes all unused java files on the
system.
D The JVM cleans output of Java program.
18 In what memory area, variable temp and
variable card written in main () get stored?
class CreditCard{
int num;

public class Bank {

public static void main(String[] args) {


int temp;
CreditCard card;

A Heap, Heap
B Stack, stack YES
C Heap, Stack
D Stack, Heap
19 Which of the following has the highest
memory requirement?
A Heap
B Stack
C JVM YES
D Class
20 Where is a new object allocated memory?
A Young space
B Old space
C Young or Old space depending on space
availability
D JVM YES
21 If an error occurs during the transaction the
troubleshoot is ____________
A delete
B rollback YES
C commit
D update
22 The variable which represents the default time
zone of the MySQL server is _____________
A time_zone YES
B system_time_zone
C date_and_time
D system_time
23 What creates the appropriate DateFormat
object and adds a day to the Date object?
A 35. DateFormat df =
DateFormat.getDateFormat();
d.setTime( (60 * 60 * 24) + d.getTime());
B 35. DateFormat df = YES
DateFormat.getDateInstance();
d.setTime( (1000 * 60 * 60 * 24) +
d.getTime());
C 35. DateFormat df =
DateFormat.getDateFormat();
d.setLocalTime( (1000*60*60*24) +
d.getLocalTime());
D 35. DateFormat df =
DateFormat.getDateInstance();
d.setLocalTime( (60 * 60 * 24) +
d.getLocalTime());
24 What will be the output by following code
snippet?
System.out.printf("%d,%f",10,20.35);
A Error
B 10,20.35
C 10,20.350000 YES
D 10,20.00
25 Consider the following object declaration
statement
Scanner objectName= new
Scanner(System.in);
What is System.in in this declaration?
A Class which point input device
B Reference to Input stream YES
C Reference to Computer System
D None of these
26 Which is the correct syntax to declare Scanner
class object?
A Scanner objectName= Scanner();
B Scanner objectName= new Scanner();
C Scanner objectName= Scanner(System.in);
D Scanner objectName= new YES
Scanner(System.in);
27 Which method does not store string value
after space?
A next() YES
B nextString()
C nextLine()
D Both 1 and 3
28 Which Scanner class method is used to read
string value from the user?
A next()
B nextString()
C nextLine()
D Both 1 and 3 YES
29 Which Scanner class method is used to read
integer value from the user?
A next()
B nextInteger()
C nextInt() YES
D readInt()
30 How to get UTC time?
A Time.getUTC();
B Date.getUTC();
C Instant.now(); YES
D TimeZone.getUTC();
31 What does LocalTime represent?
A Date without time
B Time without Date YES
C Date and Time
D Date and Time with timezone
32 How is Date stored in database?
A java.sql.Date YES
B java.util.Date
C java.sql.DateTim
D java.util.DateTime
33 How to format date from one form to
another?

A SimpleDateFormat YES
B DateFormat
C SimpleFormat
D DateConverter
34 How to convert a String to a Date object?
A SimpleDateFormat sdf = new YES
SimpleDateFormat("yyyy-mm-dd");
sdf.parse(new Date());
B SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-mm-dd");
sdf.format(new Date());
C SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-mm-dd");
new Date().parse();
D SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-mm-dd");
new Date().format();
35 How to identify if a timezone is eligible for
DayLight Saving?
A useDaylightTime() of Time class
B useDaylightTime() of Date class
C useDaylightTime() of TimeZone class YES
D useDaylightTime() of DateTime class
36
If a new object is created as an exact copy of
the existing object then it is called as _______.
A Overloading
B Overriding
C Cloning YES
D None of the above
37 Which of these classes is the superclass of
every class in Java?
A Integer
B Math
C Object YES
D Exception
38 Find the output of the below Java program?

class P {
int x = 10;
}

class Q extends P {
int y = 20;
}

class R extends Q implements Cloneable {


int z = 30;

public static void main(String[] args)


throws CloneNotSupportedException{
R r1 = new R();
R r2 = (R) r1.clone();
r1.x = 100;
r1.y = 200;
r1.z = 300;
System.out.println(r2.x+" "+r2.y+" "+r2.z);
}
}
A 100 200 300
B 10 20 30 YES
C 10 20 300
D 100 200 30
39 Find the output of the below Java program?

class Student implements Cloneable {


int id;
Student(int id) {
this.id = id;
}

public static void main(String[] args)


throws CloneNotSupportedException {
Student s1 = new Student(9);
Student s2 = (Student) s1.clone();

s1.id = 18;
System.out.println(s1.id+" "+s2.id);
}
}

A 99
B 18 9 YES
C 9 18
D 18 18
40 Find the output of the below Java program?

class Student implements Cloneable {


int id;
Student(int id) {
this.id = id;
}

public static void main(String[] args)


throws CloneNotSupportedException {
Student s1 = new Student(9);
Student s2 = s1;

s1.id = 18;
System.out.println(s1.id+" "+s2.id);
}
}
A 99
B 18 9
C 9 18
D 18 18 YES
41 Which of the following statement is true about
the Cloneable interface?

A It doesn’t contain any method. YES

B It contains only one method.

C It contains multiple methods.

D None of these

42 Which of the following statement is not


applicable for the clone() method of Object
class?
A To execute the clone() method on an object
the class must implement java.lang.Cloneable
interface.
B It is a protected method.

C It throws CloneNotSupportException.

D It is a static method. YES

43 What is the return type of clone() method in


the Object class?
A Class

B Object YES

C int

D String
44 What will be the output of the following Java
program?

class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}

A 0

B 1

C 257

D 57.0 YES

45 What will be the output of the following Java


program?

class Output
{
public static void main(String args[])
{
char a[] = {'a', '5', 'A', ' '};
System.out.print(Character.isDigit(a[0])
+ " ");
System.out.print(Character.isWhitespac
e(a[3]) + " ");
System.out.print(Character.isUpperCase
(a[2]));
}
}

A true false true

B false true true YES

C true true false

D false false false

46 Which of the following is method of wrapper


Integer for converting the value of an object
into int?
A bytevalue()
B int intValue(); YES

C Bytevalue()

D Byte Bytevalue()

47 Which of these is a wrapper for simple data


type char?
A Float

B Character YES

C String

D Integer

48 Which of these is a super class of wrappers


Long, Character & Integer?
A Long

B Digits

C Float

D Number YES

49 Which of these is a wrapper for data type int?

A Integer YES

B Long

C Byte

D Double

50 The wrapper classes are part of the which


package, that is imported by default into all
Java programs?

A java.lang YES

B java.awt

C java.io

D java.util

You might also like