Programmers at War

Create an image of a battle scene between cartoon programmers, surrounded by computer code and symbols related to programming, in a vibrant and engaging style.

Programmers at War Quiz

Test your programming knowledge with our engaging quiz designed for developers of all levels! With 10 challenging questions, you'll encounter a mix of Java fundamentals, coding concepts, and best practices.

Are you ready to put your skills to the test? Here are some features of our quiz:

  • Multiple choice questions
  • Immediate feedback on your answers
  • Learn and improve your coding skills
10 Questions2 MinutesCreated by CodingKnight542

What will be printed as the output of the following program?

public class testincr
{
public static void main(String args[])
{
int I = 0;
i = i++ + I;
System.out.println(“I = ” +i);
}
}

I = 0
I = 1
I = 2
I = 3
Compile-time Error

 What is the output of the following program:

public class testmeth
{
static int I = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}

1 , 3
3 , 1
1 , 1
1 , 0
None of the above

Consider the following code fragment


Rectangle r1 = new Rectangle();
r1.setColor(Color.blue);
Rectangle r2 = r1;
r2.setColor(Color.red);

After the above piece of code is executed, what are the colors of r1 and
r2 (in this order)?

Color.blue Color.red
Color.blue Color.blue
Color.red Color.red
Color.red Color.blue
None of the above

 Consider the two methods (within the same class)


public static int foo(int a, String s)
{
s = “Yellow”;
a=a+2;
return a;
}
public static void bar()
{
int a=3;
String s = “Blue”;
a = foo(a,s);
System.out.println(“a=”+a+” s=”+s);
}
public static void main(String args[])
{
bar();
}

What is printed on execution of these methods?

A = 3 s = Blue
A = 5 s = Yellow
A = 3 s = Yellow
a = 5 s = Blue
None of the above
Which of the following is TRUE?
In java, an instance field declared public generates a compilation error.
Int is the name of a class available in the package java.lang
Instance variable names may only contain letters and digits.
A class has always a constructor (possibly automatically supplied by the java compiler).
The more comments in a program, the faster the program runs.
What is the output of this program?

import java.awt.*;
    import java.applet.*;
    public class myapplet extends Applet
    {
        Graphic g;
        g.drawString("A Simple Applet", 20, 20);    
    }
20
Default value
Compilation Error
Runtime Error
Members of a class specified as ……………….. Are accessible only to methods of that class.
Protected
Final
Public
Private
Static
 
What is the output of this program?

class
selection_statements
{
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            if ((var2 = 1) == var1)
                System.out.print(var2);
            else 
                System.out.print(++var2);
        } 
    }
1
2
3
4
Which of these methods returns the total number of bytes of memory available to the program?
GetMemory()
TotalMemory()
SystemMemory()
GetProcessMemory()

What will this code print?

    int arr[] = new int [5];
    System.out.print(arr);
0
Value stored in arr[0]
00000
Class name@ hashcode in hexadecimal form
{"name":"Programmers at War", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your programming knowledge with our engaging quiz designed for developers of all levels! With 10 challenging questions, you'll encounter a mix of Java fundamentals, coding concepts, and best practices.Are you ready to put your skills to the test? Here are some features of our quiz:Multiple choice questionsImmediate feedback on your answersLearn and improve your coding skills","img":"https:/images/course8.png"}
Powered by: Quiz Maker