0% found this document useful (0 votes)
23 views33 pages

Java Program Compilation Components

Uploaded by

s14anj
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)
23 views33 pages

Java Program Compilation Components

Uploaded by

s14anj
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

Java Assessment Total points 42/60

Core Java

Email *

s14anjana@[Link]

0 of 0 points

Name *

sanjana Reddy

Answer for the all questions 6 of 6 points

For Switch we cannot pass ____________ data types. * 1/1

long, float, double, String

boolean, float, double, String

long, float, boolean, String

long, float, double, boolean


Which among the following is not a primitive data type in Java? * 1/1

char

String

byte

short

In switch, we can write duplicate cases * 1/1

Yes

No

Can we overload main method in java * 1/1

Yes we can

No we can't

Inside Non-static context * 1/1

can call only Non-static variables directly by its name.

can only call static variables directly by its name.

can call Non-static and static variables directly by its name.

none
what is the output for the given code * 1/1

CTE

205

206

207

10 of 12 points

Non static method will be stored in? * 1/1

Heap Area

Class Static Area

Method Area

Stack Area

None of the above


Choose the syntax to create a Object? * 1/1

Classname [Link] = classname();

Classname [Link] = new classname;

Classname [Link] = new classname();

All of the above

Which is the correct syntax for declaring static data member? * 1/1

a. memberName static dataType;

b. dataType static memberName;

c. static dataType memberName;

d. static mamberName dataType;

What is the extension of file generated by the compile? * 1/1

.class file

.java file

.javac file

.txt
In which area of memory, the system stores parameters and local *1/1
variables whenever a method is invoked?

Heap

Storage Area

Stack

Array

What is the purpose of new keyword? * 1/1

Create a constructor

Create a new class

Create a Object

None of these

How many maximum numbers of objects can be created from a single *1/1
Class in Java?

a. 32

b. 64

c. 128

d. any number of objects


How many primitive data types are there in Java? * 1/1

can you use static variable inside a method block ? * 0/1

Yes

No

The main method should be static for the reason * 1/1

It can be accessed easily by the class loader.

It can be accessed by every method or variable without any hindrance.

It can be executed without creating any instance of the class.

None of the above


Which component is used to compile, debug and execute java program? * 1/1

JVM

JDK

JIT

JRE

When are static variables loaded in memory ? * 0/1

a. during compile time

b. during object creation

c. during the constructor loading

d. None of these

1 of 3 points

12. The default values for float, boolean and string. * 1/1

a. 0.0f, true, 0

b. 0.0, false, null

c. 0.0f, false, null

d. 0, true, bull
14. What is the Output? * 0/1

a. 50.2

b. 10.8

c. 10.8f

d. 50.2f

11. Where will the memory be allocated for static variables * 0/1

a. Class static area and inside the frame in stack area.

b. Inside the Frame in stack area and class static area.

c. Both inside class static area.

d. Both inside stack area.

Section 1 25 of 39 points
Trace the code * 1/1

true

res : True

res : false

res : true

CTE
Trace the code: * 1/1

Be safe

Invalid

Compile Time Error

none of the above

Nested for-loop is possible in java? 1/1

Yes

No
Trace the code: * 1/1

s2 is greater

Both are equals

no output

s1 is greater

What is the minimum iteration of while loop and do while loop * 1/1

0 and 1

1 and 0

1 and 1

0 and 0
Break statement can be used only inside * 1/1

loops

switch

loops and swtich

none of the above

What is the output of the below Java program? * 0/1

localVariable

Compile Time Error

some other output


Trace the code... * 0/1

Class A
{
public static void main (String []args)
{
int i=1;
while (i!=5)
{
if(i%2==0) continue;
[Link](i);
i++;
}
}
}

1,3,5

2,4

CTE

5
Choose the correct syntax of the DO WHILE loop in Java below * 1/1

Option 1 Option 2

Option 3 none
What is the output? * 1/1

13579

2 4 6 8 10

2468

output will be from 1 to 10

Choose the correct syntax for the method signature. * 1/1

<methodName>

<methodName>(actual args)

<methodName>(formal args)

All the above


What is the output for the below code * 0/1

10 16

10 15

9 16

9 15
What's the output of given code..? * 0/1

Class A
{
public static void main (String []args)
{
[Link](true);
}
}

true

false

CTE

None

which is not an access modifier * 1/1

private

final

protected

default
Trace code * 1/1

CTE

1
Trace the code: * 0/1

value cannot be passed to switch statement

variable cannot be passed to case statement

WORLD

hello
Trace the code: * 1/1

Compiled Successfully, but runtime error

Compiled Successfully, No output

Compile time error

none of the above


Trace the code: * 0/1

Distinction Failed

First Class

Distinction

Just pass

Every loop in Java has a condition that should be __ in order to proceed *1/1
for execution.

true

false
What is the output of the following code snippet? * 0/1

Opp

CTE

4
Trace the code * 1/1

false

true

Error

CTE
What is the output of the Java program with IF-ELSE statements? * 0/1

GO

STOP

COMPLILE TIME ERROR

NONE OF THE ABOVE

What are the keywords used to implement a SWITCH case in Java *1/1
language?

switch, case

default

break

All of the above


Methods are : * 0/1

Block of instruction which are used to perform a specific task.

Transfer the data

both a and b

None of the above

In for loop if the condition is not provided, by default what it will take * 1/1

true

false

Depends on the last executed output

Null

Once the break statement is executed then.... * 1/1

the control will be transfered out of the loop.

the program will be terminated.

the program will continue to execute.

none of the above.


when will the method execute * 1/1

If it is not called

Only if it is called

Both a and b

none of the above

Trace the code * 0/1

10

Compile Time Error

A
Trace the code * 0/1

Infinite loop

CTE

None of the above

What's the output for given line * 1/1


[Link](0.1 + 0.2 == 0.3);

true

false

CTE

None
What is the output for the following code * 0/1

11

12

13

10
Trace the code: * 1/1

123

1234

CTE

Choose the Java-Code below with a never-ending loop. * 1/1

while(true);

for(;true;);

do{ }while(true);

All
Is main method is user defined method or pre defined method * 0/1

User defined method

Pre defined method

Is java platform dependent language * 1/1

A. NO

B. option A

I don't know...

Which type of loop is guaranteed to have the body execute at least once? * 1/1

while loop

for loop

do while loop

none
Trace the code: * 1/1

no output

compile time error

JAVA

none of the above


What is the output of the following code * 0/1

630

63

30

In Java language, BREAK or CONTINUE statements can be implemented *1/1


inside a Loop only with the help of _ statements to avoid never-ending
loops.

if else

switch

None

This content is neither created nor endorsed by Google. Report Abuse - Terms of Service - Privacy Policy

Forms

Common questions

Powered by AI

In Java, the default value for a float is 0.0f, for boolean it is false, and for a String (a reference type) it is null .

Static variables belong to the class and can be accessed directly by their name within any method, including static methods. Non-static variables, however, require an instance of the class to be accessed within non-static methods .

The 'continue' statement in Java skips the current iteration of the loop and proceeds to the next iteration. In a 'for' loop, the increment/decrement statement is executed after the 'continue', while in a 'while' or 'do-while' loop, the loop condition is re-evaluated .

Local variables and method parameters in Java are stored in the stack memory area when a method is invoked. Each method call creates a new stack frame where these variables are allocated .

Using a switch statement without a 'default' case in Java may lead to cases where none of the specific case blocks are executed if there is no match. The 'default' case acts as a fallback to handle situations not covered by the other case blocks .

The 'break' statement in Java immediately terminates the loop and transfers control to the statement following the loop. This prevents the execution of subsequent iterations of the loop .

In Java, a 'while' loop may execute 0 or more times, depending on the condition. In contrast, a 'do-while' loop always executes at least once because the condition check occurs after the loop has executed .

The main method must be static so that it can be executed by the Java Virtual Machine (JVM) without requiring an instance of the class. This makes program initialization independent of instance creation .

In Java, the String data type cannot be used with a switch statement as per older versions, although it's supported in later versions from Java 7 onwards. Primitive types like byte, short, char, and int can be used .

If the condition in a Java loop, such as in a 'for' loop, is not provided, it is assumed to be 'true', resulting in an infinite loop unless a breaking condition is explicitly defined .

You might also like