1 :-
Given the code fragment:
int array 1 [ ] = { 1, 2, 3} ;
int array 2 [ ] = new int [ 5 ] ;
array 2 = array 1 ;
for ( int i = array 2 ) ;
system . out . print ( i + “” ) :
}
system . out . println () ;
int array 3 = new int ( 3 ) ;
array 3 = array 2 ;
for ( int i = array 3 ) ;
system . out . print ( i +"" ) ;
What is the result?
2 :-
Given:
class alpha {
int ns ;
static int s ;
alpha ( int ns ) {
if ( s < ns ) {
s= ns ;
this . ns = ns ;
void do print {
system . out .println ( “ ns ” = + ns + “s = ” + s) ;
and
public class test a {
public static void main ( string [ ] args ) {
alpha ref 1 = new alpha ( 100) ;
alpha ref 3 = new alpha ( 50) ;
alpha ref 3 = new alpha ( 125) ;
ref 1 =. do print ();
ref2. do print () ;
ref 3 . do print () ;
a) ns = 100 125
ns=0s = 125
ns = 125s =125
b) ns = 50 s = 125
ns = 0s =125
c) ns= 50 s = 50
ns = 125 s =125
ns = 100s = 100
d) ns = 50 s = 50
ns = 125 s = 125
ns = 0s = 125
3 :-
Given the code snippet from a compiled Java source file:
public class my file
{
public static void main ( string [] args )
STRING ARGS 1 = ARGS [ 1 ] ;
STRING ARGS 2 = ARGS [ 2 ] ;
STRING ARGS 3 = ARGS [ 3 ] ;
SYSTEM . OUT . PRINTLN ( “ ARG IS ” + ARG 3 ) ;
}}
Which command-line arguments should you pass to the program to obtain the following output?
Arg is 2
4 :-
PUBLIC CLASS SUM TEST {
PUBLIC STATIC VOID DO SUM ( INTEGER X , INTEGER Y ) ;
SYSTEM . OUT . PRINTLN ( “ INTEGER SUM IS ” + ( “ X , Y ” ) ) ;
PUBLIC STATIC VOID DO SUM ( DOUBLE X , DOUBLE Y ) {
SYSTEM . OUT . PRINT LN ( “ DOUBLE SUM IS ” + ( X + Y ) ) ;
PUBLIC STATIC VOID DOSUM ( FLOAT X , FLOAT Y ) {
SYSTEM . OUT . PRINTLN ( “ FLOAT SUM IS ” + ( X + Y ));
5 :-
int x = 100;
int a = x++;
int b= ++x;
int c = x++;
in d = ( a< b) ? ( a< c) ? a: ( b<c) ? B: C: X :
system . out . println ( d) ;
6 :-
Which statement is true about the main() method?
7 :-
public static void main ( string [] args ) {
short s1 =200;
integer s2 = 400;
long s3 =(long)s1 +s2 ;
string s4 =(string ) (s3 *s2) ;
system . out . println ( “ sum is ” +s4 ) ;
8 :-
Which code snippet can be inserted to print Fly.Dance. ?
9 :-
Which is true?
10 :-
public class product {
int id ;
string name ;
public product ( int id , string name ) {.
this . id = id ;
this name = name ;
and give the code fragment ;
4.product p1 = new product ( 101, “ pen ” ) ;
5. product p2 = new product ( 101, “ pen ” ) ;
6. product p3 = p1 ;
7. bpplean ans1 = p1 ==p2 ;
8 . boolean ans 2 = p1 name equals ( p2 . name ) ;
9 . system . out . print ( ans 1 + “”+ ans2 ) ;
11 :-
PUBLIC CLASS TEST {
PUBLIC STATIC VOID MAIN ( STRING [] ARGS ) {
BOOLEAN A = NEW BOOLEAN ( BOOLEAN . VALUEOF ( ARGS (0 ) ) ;
BOOLEAN B = NEW BOOLEAN ( ARGS [1 ] ) ;
SYSTEM .OUT . PRINTLN ( A + “” + B) ;
And given the commands:
12 :-
public class test {
public static void main ( string [] args ) ;
test ts = new test () ;
system . out . print ( is available + “”);
is available =ts . dostuff);
public static boolean dostuff() {
return ! is available
static boolean is available = false ;
13 :-
Given the code fragment
short s1 = 200;
integer s2 = 400 ;
string s2 = ( string ) ( s1 + s2 ) ; // line n1
long s4 = ( long ) s1 + s2 ; // line n2
system . out . println ( “ sum is ” + s4 ) ;
14 :-
Which two code fragments cause a compilation error? (Choose two.)
15 :-
Which option represents the state of the num array after successful completion of the outer loop?
16 :-
Which two array initialization statements are valid? (Choose two.)
17 :-
Which two statements are true about Java byte code? (Choose two.)
18 :-
Given the code fragments:
INTERFACE EXPORTABLE {
VOID EXPORT () ;
CLASSIC TOOL IMPLEMENTS EXPORTABLE {
PUBLIC VOID EXPORT () {SYSTEM . OUT . PRINTLN ( “ TOOL :EXPORT ” );
}}CLASS REPORT TOOL EXTENDS TOOL {
VOID EXPORT () {
SYSTEM . OUT . PRINTLN ( “ RTOOL : EXPORT ” ) ;
PUBLIC STATIC VOID MAIN ( STRING [ ] ARGS ) {
TOOL BTOOL = NEW TOOL () ;
CALL EXPORT ( ATOOL ) ;
CALL EXPORT ( B TOOL) ;
PUBLIC STATIC VOID CALLEXPORT ( EXPORTABLE EX ) {
EX. EXPORT () ;
19 :-
string str = “” ;
str , trim () ;
system . out . println ( str . equals ( “” ) + “” + ste is empty ()) ;
20 :-
Given this array:
int [ ] int arr= { 8, 16, 32 ,64, 128 };
Which two code fragments, independently, print each element in this array? (Choose two.)
a) FOR ( INT I = INT I : INT ARR ) {
SYSTEM . OUT . PRINT ( INT ARR[ I] + “” ) ;
B) FOR ( INT I : INT ARR ) {
SYSTEM OUT . PRINT ( I + “”);
C) FOR ( INT I = 0 ; INT ARR) {
. system . out . print ( int arr[ i ] + “”);
d) for ( int i = 0 ; < int arr . length ; i ++ ) {
system . out . print ( i + “”) ;
e ) for ( int i = 0 ; i < int arr . length ; i ++ ) {
system . out . print ( int arr [ i] + “” );
Tips for improving your score: