0% found this document useful (0 votes)
15 views

Java Murged Final

Uploaded by

kj2jbxr7pc
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)
15 views

Java Murged Final

Uploaded by

kj2jbxr7pc
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
You are on page 1/ 18

Mockwarriors

Topic Test – Basic Java


Specially Design For RPSC Programmer Exam
Time – 15 Minutes. Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1. What is the output of the following code snippet?


int x = 20;
int y = 20;
int z = x++ + ++y;
System.out.println(z);
a) 41
b) 42
c) 43
d) 44

Q2. Which of the following is not a valid identifier in Java?


a) $coder
b) _ programmer
c) 123programmer
d) programmer_123

Q3. Find the output of the following code:


public static void main(String args[])
{
int i = -1;
while (i < 5) {
System.out.print(i + " ");
i++;
}
}
a) -1 0 1 2 3 4
b) -1 1 2 3 4 5
c) 0 1 2 3 4 5
d) -1 2 3 4 5 6

Q4. which is the first line (if any) that causes a compilation error ?
public static void main(String args[])
{
char c;
int i;
c = 'A'; // 1
i = c; //2
c = i + 1; //3
c++; //
}
a) The line labeled 1.
b) The line labeled 2.
c) The line labeled 3.
d) The line labeled 4.

Q5. Which of these assignments are Not Valid ?


a) short s = 28;
b) float f = 2.3;
c) int I = '1';
d) byte b = 12;

Q6. Find the output of the following code:


public static void main(String args[])
{
byte x = 3;
x = (byte)~x;
System.out.println(x);
}
a) -1
b) -3
c) +3
d) -4

Q7. Find the output of the following code:


public static void main(String args[])
{
int x,y;
x = 1 & 8;
y = 3 ^ 5;
System.out.println(x + " " + y);
}
a) 0 6
b) 6 0
c) 8 0
d) 0 8

Q8. Find the output of the following code:


public static void main(String args[])
{
int x, y;
x = 5 >> 2;
y = x >>> 2;
System.out.println(y);
}
a) 1
b) 2
c) 3
d) 0

Q9. Find the output of the following code:


public static void main(String args[])
{
System.out.println(1/9 + 5/2 + 0.1);
}
a) 1.1
b) 2.1
c) 3.1
d) 3

Q10. Find the output of the following code:


public static void main(String args[])
{
int i = 5;
boolean t = true;
boolean f = false, b;
b = (t | ((i++) == 0));
b = (f | ((i+=2) > 0));
System.out.println(i);
}
a) 6
b) 7s
c) 8
d) 9

Ansker Key will Be updated Here


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Answer-Key – Basic Java
Specially Design For RPSC Programmer Exam
Answer Key Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1 A
Q2 C
Q3 A
Q4 C
Q5 B
Q6 D
Q7 A
Q8 D
Q9 B
Q10 C

Click Here To View Question Paper


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Topic Test – Basic Java Test 2
Specially Design For RPSC Programmer Exam
Time – 15 Minutes. Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1. What is the output of the following code:


class Mockwarriors{
public static void main(String[] args)
{
int a = 10;
int b = 20;
if (++a <= 10 && --b < 20) {}
System.out.println("a = " + a + " b = " + b);
a = 10;
b = 20;
if (++a <= 10 & --b < 20) {}
System.out.println("a = " + a + " b = " + b);
}
}
a) a = 11 b = 20
a = 12 b = 18
b) a = 11 b = 20
a = 11 b = 19
c) a = 10 b = 20
a = 11 b = 19
d) a = 11 b = 20
a = 11 b = 18

Q2. What is the output of the following code:


class Mockwarriors{

public static void main(String[] args)


{
int a = 10;
int b = 20;
if (++a <= 10 || --b < 20) {}
System.out.println("a = " + a + " b = " + b);
a = 10;
b = 20;
if (++a <= 10 | --b < 20) {}
System.out.println("a = " + a + " b = " + b);
}
}
a) a = 11 b = 20
a = 12 b = 18
b) a = 11 b = 20
a = 11 b = 19
c) a = 11 b = 19
a = 11 b = 19
d) a = 11 b = 20
a = 11 b = 18

Q3. What is the output of the following code:


class Mockwarriors {
public static void main(String args[]) {
int[] a = {1, 2, 3, 4, 5, 6};
int i = a.length - 1;
while (i >= 0) {
System.out.print(a[i]);
i--;
}
}
}
a) 654321
b) 6543210
c) 123456
d) 0123456

Q4. What is the output of the following code:


class Mockwarriors{
static int x = 10;
public static void main(String[] args)
{
for(int x=0;x<5;x++){}
System.out.print(x);
}
}
a) 10
b) 012345
c) 12345
d) 123456789

Q5. What is the output of the following code:


class Mockwarriors {
public static void main(String args[]) {
short p=1; // Line 1
short k=0; // Line 2
k=p+1; // Line 3
System.out.println(k);
}
}
a) 1
b) Error Because of Line 1
c) Error Because of Line 2
d) Error Because of Line 3

Q6. What is the output of the following code:


class Mockwarriors {
public static void main (String args[])
{
for (int i = 0; i < 3; i++)
{
for (int j = 3; j <= 0; j--)
{
if (i == j) continue;
System.out.println(i + " " + j);
}
}
}
}
a) blank
b) 0
c) 321
d) 123

Q7. What is the output of the following code:


class Mockwarriors{
public static void main(String args[])
{
boolean x = true;
int a;
if(x) a = x ? 1: 2;
else a = x ? 3: 4;
System.out.println(a);
}
}
a) 1
b) 2
c) 3
d) 4

Q8. Which of the following is not legal identifiers?


a) _4_
b) @name
c) getSize
d) $

Q9. Which of the following for loop declaration is not valid?


a) for ( int j = 7; j <= 77; j += 7 )

b) for ( int j = 20; j >= 2; --j )


c) for ( int j = 2; j <= 20; j = 2* j )

d) for ( int j = 99; j >= 0; j / 9 )

Q10. What is the output of the following code:


class Mockwarriors{
public static void main(String args[])
{
int x = 1;
int y = 2;
int z = x++;
int a = --y;
int b = z--;
b += ++z;
int answ = x>a?y>b?y:b:x>z?x:z;
System.out.println(answ);
}
}
a) 1
b) 2
c) 3
d) 4

Ansker Key will Be updated Here


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Answer-Key – Basic Java Test 2
Specially Design For RPSC Programmer Exam
Answer Key Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1 B
Q2 C
Q3 A
Q4 A
Q5 D
Q6 A
Q7 A
Q8 B
Q9 D
Q10 B

Click Here To View Question Paper


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Topic Test – Basic Java Test 3
Specially Design For RPSC Programmer Exam
Time – 15 Minutes. Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1. What is the default value of a char in Java?


a) '0'
b) ' '
c) '\u0000'
d) '\uffff'

Q2. Find the output:


class A {
int i;
}
class B extends A {
int j;
void display()
{
super.i = j + 1;
System.out.println(j + " " + i);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i = 1;
obj.j = 2;
obj.display();
}
}
a) 2 3
b) 2 4
c) 4 3
d) 1 2

Q3. Redefining the super class method in the subclass is known as __


a) Dynamic Binding
b) Method Overloading
c) Method Overriding
d) None of These

Q4. Which of the following is a valid abstract class?


a) class A { abstract void test() {} }
b) class A { abstract void test(); }
c) abstract class A { abstract void test(); }
d) public class abstract A { abstract void test(); }

Q5. Which of the following declares an abstract method in an abstract Java class?
a) public abstract method();
b) public abstract void method();
c) public void method() {}
d) public void abstract Method();

Q6. Find the output:


class Mockwarriors {
public static void main (String args[])
{
byte x=1;
x+=11;
System.out.println(x);
}
}
a) 2
b) 12
c) 11
d) Compilation Error

Q7. Error Occurs Because of


class Mockwarriors {
public static void main (String args[])
{
byte x=1;
x+=11; // Line 1
x=x+10; // Line 2
x++; // Line 3
x--; // Line 4
System.out.println(x);
}
}
a) Line 1 and Line 2
b) Line 3 and Line 4
c) Only Line 2
d) Line 2, Line 3 and Line 4

Q8. Find the output:


class Mockwarriors {
void sum() {
int age=5;
System.out.println(age);
}
public static void main(String args[]) {
Mockwarriors test = new Mockwarriors();
test.sum();
}
}
a) 1
b) 0
c) 5
d) Compilation Error

Q9. Find the output:


class Mockwarriors {
static int age;
void sum() {
int age=5;
System.out.println(age);
}
public static void main(String args[]) {
Mockwarriors test = new Mockwarriors();
test.sum();
}
}
a) 1
b) 0
c) 5
d) Compilation Error

Q10. Modulus operator(%) In Java, can be applied to which of these?


a) Both Integers and floating – point numbers
b) Integers
c) Floating – point numbers
d) None of the mentioned

Answer Key will Be updated Here


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Answer-Key – Basic Java Test 3
Specially Design For RPSC Programmer Exam
Answer Key Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1 C
Q2 A
Q3 C
Q4 C
Q5 B
Q6 B
Q7 C
Q8 C
Q9 C
Q10 A

Click Here To View Question Paper


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Topic Test – Basic Java Test 4
Specially Design For RPSC Programmer Exam
Time – 15 Minutes. Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1. What is the output of the following code:


class Mockwarriors{
public static void main(String[] args) { int a[][] = new int[3][];
a[1] = new int[]{1,2,3};
a[2] = new int[]{4,5};
System.out.print(a[1][1]);
}}
a) 1
b) 2
c) 3
d) 4

Q2. What is the output of the following code:


class Warriors{
void sum() {
static int age=5;
System.out.println(age);
}
public static void main(String args[]) {
Warriors test = new Warriors();
test.sum();
}
}
a) 5
b) 0
c) Compilation Error
d) Runtime Error

Q3. What is the output of the following code:


class Warriors{
void sum() {
int Static=5;
System.out.println(Static);
}
public static void main(String args[]) {
Warriors test = new Warriors();
test.sum();
}
}
a) 5
b) 0
c) Compilation Error
d) Runtime Error

Q4. What is the output of the following code:


class MockWarriors{
static {
char Char='A';
System.out.println(Char);
}
{
System.out.println("Instance Called");
}
public static void main(String args[]) {
}
}
a) A
b) A
Instance Called
c) Compilation Error
d) Runtime Error

Q5. What is the output of the following code:


class MockWarriors{
static {
String Char="MockWarriors";
System.out.println(Char);
}
{
System.out.println("Join Our Telegram");
}
public static void main(String args[]) {
MockWarriors r= new MockWarriors();
new MockWarriors();
}
}
a) MockWarriors
Join Our Telegram
b) MockWarriors
Join Our Telegram
Join Our Telegram
c) No Output
d) MockWarriors
Join Our Telegram
Join Our Telegram
Join Our Telegram
Q6. What is the output of the following code:
class Warriors{
static {
String $="MockWarriors";
System.out.println($);
}
{
System.out.println("Join Our Telegram");
}
Warriors(){
System.out.println("Channel For More Content");
}
public static void main(String args[]) {
new Warriors();
}
}
a) Error
b) Join Our Telegram
Channel For More Content
c) No Output
d) MockWarriors
Join Our Telegram
Channel For More Content

Q7. What is the output of the following code:


class Warriors{
static {
new Warriors();
String $="MockWarriors";
System.out.println($);
}
Warriors(){
System.out.println("Join Our Community");
}
public static void main(String args[]) {
}
}
a) Error
b) Join Our Community
MockWarriors
c) MockWarriors
Join Our Community
d) No Output

Telegram- @Mockwarriors_itexam
Q8. What is the output of the following code:
class MockWarriors{
{
System.out.println("Finally Joined Our Community");
}
public static void main(String args[]) {
}
}
a) Finally Joined Our Community
b) no output
c) Run Time Error
d) Compilation Error

Q9. Which of the following is a correct method declaration in Java?


a) public int mockWarriors(int a, int b)
b) public mockWarriors(int a, int b): int
c) mockWarriors{int a, int b}
d) mockWarriors[int a, int b]

Q10. Which of the following is a correct method declaration in Java?


1) MockWarriors
2) _mockWarriors
3) 5mockWarriors
4) mockWarriors5

a) Only 2
b) Both 1 and 2
c) Both 1, 2 and 4
d) Only 3

Answer Key will Be updated Here


Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com
Mockwarriors
Answer-Key – Basic Java Test 4
Specially Design For RPSC Programmer Exam
Answer Key Telegram- @Mockwarriors_itexam www.MOCKWARRIORS.com

Q1 B
Q2 C
Q3 A
Q4 A
Q5 B
Q6 D
Q7 B
Q8 B
Q9 A
Q10 C

Telegram- @Mockwarriors_itexam
www.MOCKWARRIORS.com

You might also like