Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Think you’ve got the basics of Java code structure down? Take this fun quiz to challenge yourself and see how well you can write proper Java programs! Whether you’re a coding whiz or a complete beginner, this quiz is a super way to test your knowledge of Java syntax rules.
We’ll throw all sorts of questions your way to see if you can spot the correctly written code snippets, identify mistakes, and understand how to build a well-structured Java program. Don’t worry, there are no tricks here, just a chance to learn and practice the building blocks of Java! Let’s test your knowledge.
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 correct syntax for a class name?
CorrectIncorrect -
Question 2 of 15
2. Question
What is the output of the program?
public class sample{
public static void main(String args [] )
{
final int a = 2;
a = 5;
system .out.println(a);
}
}
CorrectIncorrect -
Question 3 of 15
3. Question
Public class demo {
Public static void main(String args [] )
{
String Firstname = “Data”;
String Lastname = “Flair”;
system.out.println(*********);
}
}
CorrectIncorrect -
Question 4 of 15
4. Question
While creating an object the syntax should include ?
CorrectIncorrect -
Question 5 of 15
5. Question
How to declare a Scanner class named sc?
import java.util.*;
class UserInputDemo1
{
public static void main(String[] args)
{
_______________________________
System.out.print(“Enter a string: “);
String str= sc.nextLine();
System.out.print(“Entered string is: “+str);
}
}
CorrectIncorrect -
Question 6 of 15
6. Question
Whenever a method is invoked the parameters and other variables are stored in which area of memory location?
CorrectIncorrect -
Question 7 of 15
7. Question
Access Modifiers which cannot be used for constructors are ?
CorrectIncorrect -
Question 8 of 15
8. Question
Which method is used for Garbage collection?
CorrectIncorrect -
Question 9 of 15
9. Question
How to declare and call a method?
CorrectIncorrect -
Question 10 of 15
10. Question
What will be the output of the program?
public class Example {
public static void main(String[] args) {
StringBuffer name = new StringBuffer(“DetaFoair”);
s1.setCharAt(1,’a’);
s1.setCharAt(6,’l’);
System.out.println(name);
}
}
CorrectIncorrect -
Question 11 of 15
11. Question
What is the name of the concept which uses a pre-compiled code for further executions ?
CorrectIncorrect -
Question 12 of 15
12. Question
What will be the output of the program?
public class Student {
private String name;
private String college;
public Student(String name, String college) {
super();
this.name = name;
this.college = college;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCollege() {
return college;
}
public void setCollege(String college) {
this.college = college;
}
public static void main(String[] args) {
Student student = new Student(“karthick”, “Skasc”);
Student student2 = new Student(“Jerome”, “Nasc”);
Student student3 = new Student(“Kamrizdeen”, “Kcas”);
}
}
CorrectIncorrect -
Question 13 of 15
13. Question
What is the main advantage in using Methods in Java ?
CorrectIncorrect -
Question 14 of 15
14. Question
Which Object is used for creation only with no reference ?
CorrectIncorrect -
Question 15 of 15
15. Question
The given program is an example of which class?
. final class A
{
void printmsg()
{
System.out.print(“Base class method is executed.”);
}
}
class B extends A
{
void printmsg()
{
System.out.print(“Derived class method is executed.”);
}
}
public class ClassExample
{
public static void main(String[] arg)
{
B obj = new B();
obj.printmsg();
}
}
CorrectIncorrect
Summary:
So how did you fare on the Java syntax quiz? This short assessment covered essential concepts like class naming conventions. Remember, a strong foundation in syntax is crucial for building robust and well-structured Java applications.
If you aced the quiz, congratulations! If you encounter some challenges, don’t worry! This serves as a valuable learning opportunity. Utilize the provided resources, such as the links to tutorials and online communities, to delve deeper into specific syntax topics and solidify your understanding. Keep practising and exploring, and you’ll be well on your way to mastering Java syntax!
