Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

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

You might also like