VMware Code Snippets Questions and ANSWERS Quiz-1

Question 1

Time: 00:00:00
What is the output of this C code?

#include
void main()
{
int x = 97;
int y = sizeof(x++);
printf("x is %d", x);
}

x is 97

x is 97

x is 98

x is 98

x is 99

x is 99

Run time error

Run time error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What is the output of the below c code?

#include
void main()
{
char *s = "hello";
char *p = s;
printf("%p\t%p", p, s);
}

Different address is printed

Different address is printed

Same address is printed

Same address is printed

Run time error

Run time error

Nothing

Nothing

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
What is the output of this C code?

#include
#define foo(m, n) m * n = 10
int main()
{
printf("in main\n");
}

In main

In main

Compilation error as lvalue is required for the expression m*n=10

Compilation error as lvalue is required for the expression m*n=10

Preprocessor error as lvalue is required for the expression m*n=10

Preprocessor error as lvalue is required for the expression m*n=10

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Which of the following code fragments inserted, will allow compiling?

public class Outer
{
public void someOuterMethod()
{
//Line 5
}
public class Inner { }

public static void main(String[] argv)
{
Outer ot = new Outer();
//Line 10
}
}

new Inner(); //At line 5

new Inner(); //At line 5

new Inner(); //At line 10

new Inner(); //At line 10

new ot.Inner(); //At line 10

new ot.Inner(); //At line 10

new Outer.Inner(); //At line 10

new Outer.Inner(); //At line 10

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00

What is the widest valid returnType for method in line 3?

public class ReturnIt
{
returnType methodA(byte x, double y) /* Line 3 */
{
return (long)x / y * 2;
}
}

int

int

byte

byte

long

long

double

double

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
What will be the output of the program?

class A
{
final public int GetResult(int a, int b) { return 0; }
}
class B extends A
{
public int GetResult(int a, int b) {return 1; }
}
public class Test
{
public static void main(String args[])
{
B b = new B();
System.out.println("x = " + b.GetResult(0, 1));
}
}

x = 0

x = 0

x = 1

x = 1

Compilation fails.

Compilation fails.

An exception is thrown at runtime.

An exception is thrown at runtime.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What will be the output of the program?

public class Test
{
public static void main(String args[])
{
class Foo
{
public int i = 3;
}
Object o = (Object)new Foo();
Foo foo = (Foo)o;
System.out.println("i = " + foo.i);
}
}

i = 3

i = 3

Compilation fails.

Compilation fails.

i = 5

i = 5

A ClassCastException will occur.

A ClassCastException will occur.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What will be the output of the program?


public class A
{
void A() /* Line 3 */
{
System.out.println("Class A");
}
public static void main(String[] args)
{
new A();
}
}

Class A

Class A

Compilation fails.

Compilation fails.

An exception is thrown at line 3.

An exception is thrown at line 3.

The code executes with no output.

The code executes with no output.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice! \r\n","Keep trying! \r\n","Not bad! \r\n","Good work! \r\n","Perfect! \r\n"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/8

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments