Quiz on Java Static Methods
Free Java courses with 37 real-time projects - Learn Java
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
Which of the following is the correct way to invoke a static method ?
CorrectIncorrect - Question 2 of 15
2. Question
class Method {
static void square(int a)
{
return(a*a);
}
public static void main ( String args [ ] )
{
System.out.println(square(5));
}
}
What is the output of the program ?
CorrectIncorrect - Question 3 of 15
3. Question
class Function {
void display()
{
system.out.println(“Non-static method”);
}
}
class Main {
public static void main ( String args [ ] )
{
Function.display();
}
}
What will be the output of the program ?
CorrectIncorrect - Question 4 of 15
4. Question
Which of the following cannot be done using the static methods in java?
CorrectIncorrect - Question 5 of 15
5. Question
class One {
static addition(int a , int b)
{
return a+b;
}
static subtraction(int a , int b)
{
return a-b;
}
public static void main ( String args [ ] )
{
System.out.println(addition(2,3)+”,”+subtraction(3,2));
}
}
What will be the output of the program ?
CorrectIncorrect - Question 6 of 15
6. Question
class A {
static method1()
{
System.out.println(“Static method”);
}
}
class Main {
public static void main ( String args [ ] )
{
method1();
}
}
What is the error in the program ?
CorrectIncorrect - Question 7 of 15
7. Question
Which of the following keywords raise an error in static methods ?
CorrectIncorrect - Question 8 of 15
8. Question
class Text {
String name = “ ”;
static void display(string a)
{
name = a;
System.out.println(name);
}
public void print(String b)
{
name = b;
System.out.println(name);
}
}
class Main {
public static void main ( String args [ ] )
{
Text.display(“DataFlair”);
Text t = new Text();
t.print(“Webservices”);
}
}
What should be the output of the program ?
CorrectIncorrect - Question 9 of 15
9. Question
class Main {
public static void main ( String args [ ] )
{
static void method(int a , int b , int c )
{
return a*b*c*;
}
method(10.9.8);
}
}
What will be the output of the program ?
CorrectIncorrect - Question 10 of 15
10. Question
Which of the following is the syntax for invoking static methods ?
CorrectIncorrect - Question 11 of 15
11. Question
class Objects {
Static void display()
{
System.out.println(“static class method”);
}
}
class Main {
public static void main ( String args [ ] )
{
Objects obj = new Objects();
obj.display();
}
}
What is the output of the program ?
CorrectIncorrect - Question 12 of 15
12. Question
class Method {
int b;
Method(static int a)
{
b = this.a;
system.out.println(b);
}
public static void main ( String args [ ] )
{
Method m = new Method(10);
}
}
What is the output of the program ?
CorrectIncorrect - Question 13 of 15
13. Question
Which of the following concepts are used in static methods ?
CorrectIncorrect - Question 14 of 15
14. Question
class StaticMethods {
public static void main ( String args [ ] )
{
static int b = 10;
static void value( b)
{
Static int a = b*b;
}
System.out.println(a);
}
}
What is the output of the program ?
CorrectIncorrect - Question 15 of 15
15. Question
class Sample {
static void calculate( int x )
{
System.out.println(3.14*x*x);
}
}
class Main {
public static void main ( String args [ ] )
{
Sample.calculate(4);
}
}
What will be the output of the program ?
CorrectIncorrect
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google