0% found this document useful (0 votes)
19 views5 pages

Integra Micro Software Services Test

The document is a test paper from Integra Micro Software Services containing multiple-choice questions related to Java programming. It includes instructions for marking answers and specifies the scoring system for correct and incorrect responses. The questions cover various Java concepts, including syntax, data types, and object-oriented programming principles.

Uploaded by

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

Integra Micro Software Services Test

The document is a test paper from Integra Micro Software Services containing multiple-choice questions related to Java programming. It includes instructions for marking answers and specifies the scoring system for correct and incorrect responses. The questions cover various Java concepts, including syntax, data types, and object-oriented programming principles.

Uploaded by

Vpn Account
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

oftaare Integra Micro Software Services (P)Ltd.

integra niero
ere9
Version 1.3 21-Dec-2222

Section II Test Code: BJC


Instructions:
sheet provided.
Mark your answers under Section III in the OMR
sheet.
Please write the test code on your answer
Maximum time allotted: 20 minutes
1 mark will be awarded for every correct answer and 025 mark will be deducted For
every Wrong answer.
Use extra sheets for rough work.
Mark your answer by filling in the appropriate bubble as shown below:
a b

Questions:

1. Which of the following answers return true when you replace in the place of
XXXXXXXXX?
public class Test Type {
public static void main(String args[]) {
Button b = new Button ("BUTTON") :
if( XXXXXXXXX) {
[Link] .print ("This is an instance of Buton") ;

[a] b instanceof Button


[b] Button
[c] b == Buttoninstanceof b
[d] Button
=(0bject) b
2. What is the
result of
public class Test { compiling the following code?
public static void main ( String [] args) {
int value;
value = value + 1;
) [Link](" The value is:" + value):
[a] Compile and runs with no
|b] Compiles and runs output
[c] Does not printing out "The value is 1"
[d] compile
Compiles but generates run time error
3. Which of
[a) goto [b]the fol1lowing are Java
synchronized keywords or
reserved
implements words?
[c] extends [d] [e] A1l of the
4. What is the above
[a] 0 to numeric range for a Java int
(2^32)
[b] - (2^31) to data type?
[c] -(2^31) to (2^31)
[d] - (2^15) to (2^31 - 1)
(2^15 - 1)
. Select all
[a) valid identifiers from the
lhello hello [c] ^hello [d)following?
[b]
b. What is the
#hello [e) none of the
above
[a] package, correct order in list given below?
[b] import, class
class, import, package
[c] import, package, class
[d] package,
class, import
equal WEappers
are "These output No(e)
error, Runtime [b]td] error time Compile (a]
equal") wEappers
aEe (These
System,outprintln
[Link]
(bl)
) LE
(false) : Boolean ew Boolean

(true)1 Bo0lean b new Boolean
equal)s out-println
are ("Both System.
One)a (7est s2new
One) ("Test String StEing StEing
L[1) args(String new String sl
ain void static public
progran? EOllwing MyClass class public
"true followed result
oE the bewi1l What
by equal" 10.
are output No(c]
arroE Runtima th"Bo [(bd]]
error tine Compile [a]
("true): .println [Link]
[Link]
(bl)
) 1E
false: boolean
bl
truez booleanb
equal"la are ("Both printin System.
[Link]( out
One): str2)
("Test String) nex ( 1f
One: str2
- String
args[l) (String Test strl String
main void static Public
progran? folloing MyClass class Public
result
of the bewill What 9
600 isvalue xThe (d] 400 value
is
30. value
s xThe (b] Thex [e]
20 value
is xThe [a]
y y xAnt
y)l (intmethod vOLd
x)1 is
value ("The
.printin
x Systen,out
[Link]
(x#)
()E ytest ne ta
Mytest
201 xint
main(String
[]
)args void static public
30: xLnt
MyTest class public
oode?following the rosult
of the isWhat 8.
pinted screan the printed
on is
World Hello Ls sofvalue The d]
output
is No[e) error time Compile (a]
error Runtime [b]
Ls value
of (The out-print
ln System.
6)1 length()
> s. null)
&& (isl 1f
Strings-Hello
World":
L1) in(String
args sa
void static ic
publ
TestBitL class public
answers? of1ist the Eora answer correct the Select 7.
Serv ohwar Micro integra
signature different
signature different and name method same
and name method the have methodsOverloaded
signature and name nethod same the have thods Overridden [d]
signature same me
the have methods Overloaded [c]
and name method same [b]
the have methods Overridden
true? statements
are [a]
the Which
of 17.
Employee Person
Employee extends class public [d]
Employee extendsextends PersonPerson transient
Employee extends class native [c]
Person class private [b]
legal, are Person class class? existing [a]
level declarations
top is
followinganEmployee assuming
[Link]; [d]of the ofWhich 16.
length
i()arrayName. [b]
[Link]() ;
array? an length length;arrayName. [c]
of the find toused following (al
is the Which
of 15.
efined. are they where methods modifier
for
nethod. class implementation
the in a istati valid (d]s
main
() from called nohave thods Abstractme
bemodifier
can access (c]
method? defining with Methods
no (b]
about true modifier.
statements valid Transient
a is
are following (a]
the of ch
Whi I4.
execution");) ("Statig above the ofAll Ie)
print out. tem. Sys tic( ta s[d]
35; t= protected
int [a]
=[Link]; doubled transient (b]
""; =String
s priva
te [a)
valid? declarations
are ollowing the ofWhich 13.
this
;() [d] super
i() [c] (100) ; this [b] (100); super [a]
B()7 new Bb
])args(String main void static publiC
{B)
Bextends
( A class public
{} i)
A(int
class
A
line//xxxxx?
comment the replace
at answer
to correct the select code, piece
of the Given 12.
error time Run Ld]
Constructor error time Compile [al
Construtor Class
A followed
by Construator Class
B
Class
B followed
by Constructor [b]
Class
A [a)
B() new Bb=
))args (String main void static publiC
Constructor")i ("Class
[Link]
B System,
extends
( A class
B publiG
Constructor")7 ("ClassA [Link]
ln System,
code?following texecute
he classA
you when printed bewill What
Ltd. Services
(P) Software Micro Integra 11.
printed is 100 Only [d] printed
100,200,300 values The
printed Nothing [e]
error time Compile [b] is [a]
break;
[Link]
(i) ; ln System.
300: Case
break;
[Link](i) ; System.
200: Case
break;
.println
(i) ; System.
out
100: case
{(i) switch
100; = i int
code?
following the run andcompile you when result the is What 21.
1ls: j value
of The 1; is: i of
value The [e]
is:0 j value
of The 1; is: i value
of The Ld]
2is: value
j of The 0; is: i of
value The [c]
1is: j of
value The 0; is: i value
of The (b]
0is: value
j of The 0; is: i value
of The [a]
j): "+ is: i of
value ("The
.println out System.
): i t "is: i ofvalue [Link]
("The System.
outer; Continue
*j) i ( if
jt+) 3; < j 0; = j int (for
( it+) i
2; < i 0; = (int for outer:
program the output
of the is What 20.
run? compile
and you if following
abstract, defined
as cannot
be Methods [e]
t. variables
be can only
Test
;() voidabstract final [d]
:Test
() void
abstract static [c]
()
0 Test voidabstract [b]
Test
;() voidabstract [a]
following the Whi
of ch 19.
define toways valid are
ethod. abstract an
printed Fourth
is [e]
printed is
Third [d]
printed Second
is [c)
printed is
First (b)
printed Nothing
is [a]
System.
out
("Eourth"): .printin
else(
("Third"):
[Link],print
ln
>,5) (e ifelse
ln("Second")
[Link]
:
else
[Link]
.print
("Erist
"): ln
b6, e 0, aint 18.
10:
result the i8Nhat
compile you when
following the run and
code?
method start
() completing
the after dies 1nread
nethod. ()
run [a]
run eligible inlies body Thread [c]
to makes
it method start
() Thread [D]
extet interface
or Runnable inplements either Thread,
true? statements new create Class
a 10 ba)
are following the Wnich
of 25.
PointerException:
demo [Link] [Link]:
followed
by demoMethod. inside Caught
printed. thing
issuccessfully, d]
no Compile [c]
error Runtime [b]
error
Compilation [a]
("Recaught:
e); +"
PointerException [Link]
ln System.
{ e) catch
demoMethod()(Null
; }
{[|) args(String in ma
void static public try
exception re-thrOw
the
demoMethod.
")
: inside ("Caught
[Link] // chrow
interException System., e
("demo") : Exception e) Pointer (Null
Po catch
Null new throw
(try
thod
()demoMe void static
run? andcompile ThrowDemo( class public
you when following
code the result
of the isWhat 24.
Thread running currently above the ofAll [e)
the kills thod me () stop (d]
A
again. started becanThread dead La]
returns A
method ()run the after dies Thread
run. eligible
to 1t
makes nethod b]
start) Thread a)
true? statements
are following the af ch Wi 23.
the
natifyAll()above and stap)ofAll [Lad]l
destroy() and 0zua [cl
resume() and st)ag 2]
notify() and wait() [al
threadcontrolling for used best cmicaticn?
are pairs nathod follawing the Which
af 22.
LAd Senices
(P) Sotware Micro Integra

Common questions

Powered by AI

Java's exception handling facilitates robustness and effective error management by separating error-handling code from regular code logic using try-catch blocks. This allows programmers to address errors systematically and predictably. By leveraging checked exceptions, Java compels developers to consider error handling, enhancing reliability. The try-catch mechanism, alongside finally blocks for cleanup, ensures that resources can be managed effectively even in error scenarios, thereby maintaining application stability and reliability .

The Java compiler plays a crucial role in managing memory allocation by determining the memory layout for both primitive data types and reference variables. Primitive types are stored in the stack memory, providing fast access with a fixed size dependent on the data type. Reference variables, on the other hand, store addresses pointing to objects in heap memory, allowing dynamic allocation and garbage collection to free unused memory .

Java's garbage collection process optimizes memory utilization by automatically reclaiming memory occupied by objects that are no longer reachable from the running application. The garbage collector tracks references to objects, identifying those that can be freed when no references remain. By periodically running this process, Java ensures efficient memory management and reduces the programmer's burden of manual deallocation, which minimizes memory leaks and enhances application performance .

Java provides several mechanisms for concurrency, including the Thread class, the Runnable interface, and higher-level utilities from 'java.util.concurrent'. The Thread class enables creating threads with defined behaviors, while the Runnable interface allows defining a task to be executed by a thread. Higher-level utilities, like ExecutorService, facilitate thread management by abstracting details of thread creation and management, focusing on tasks instead of threads. These tools provide various levels of control over thread lifecycle, workload distribution, and resource management .

A Java class must be declared abstract if it contains an abstract method because abstract classes provide incomplete implementations that are meant to be completed by subclasses. If a class with an abstract method is not declared abstract, it leads to a compile-time error because the class would seem to mandate implementation of a method that is not possible to implement without being concrete, which defies Java's requirement for class completeness .

In the given code, the integer variable 'value' must be explicitly initialized before it can be used in an expression. To correct this, 'value' should be initialized to a starting integer, such as 'int value = 0;'. After this correction, the statement 'value = value + 1;' will increment the initialized value by 1, resulting in 'The value is: 1' being printed .

The 'transient' modifier in Java is used to indicate that a field should not be serialized. When an object is serialized, transient variables are not included in the serialized representation. This is useful for fields that derive their value from a source that should not be included in serialization (like a file handle) or for security reasons to prevent sensitive data from being serialized .

Access modifiers in Java (public, private, protected, and default) control the visibility and accessibility of class members such as fields and methods. 'Public' allows access from any other class, 'private' restricts access to within the same class, 'protected' allows access within the package and by subclasses, and 'default' (no modifier) restricts access to within the same package. They are important for encapsulation, information hiding, and in defining a class's API, ensuring controlled access and modification of class data .

Method overriding in Java occurs when a subclass provides a specific implementation for a method already defined in its superclass with the same method signature, including name, parameter list, and return type. In contrast, method overloading happens within the same class, where multiple methods have the same name but different signatures, i.e., different parameter lists, allowing for various uses of a method based on input parameters .

If instance variables in Java are not explicitly initialized by the programmer, they are automatically initialized with default values by the Java compiler. This ensures that all instance variables have a predictable initial state, which is crucial to prevent undefined behavior in Java programs. For example, numeric types are initialized to zero, boolean types to false, and object references to null .

You might also like