Java Test 1

Java Test 1

10th Grade

15 Qs

quiz-placeholder

Similar activities

user defined methods in java

user defined methods in java

10th Grade

13 Qs

Computer Science: Chapter 1 Test Review

Computer Science: Chapter 1 Test Review

9th - 12th Grade

20 Qs

Intro to Java - Primitives vs. Objects

Intro to Java - Primitives vs. Objects

9th - 12th Grade

16 Qs

8.12 C++ Test on Classes

8.12 C++ Test on Classes

9th - 12th Grade

15 Qs

Grade 10 - Final Exam practice quiz

Grade 10 - Final Exam practice quiz

10th Grade

19 Qs

Kuis Dadakan ;)

Kuis Dadakan ;)

10th Grade - University

15 Qs

L-1 & L-2 of Computer Applications

L-1 & L-2 of Computer Applications

9th - 10th Grade

15 Qs

Java- Session: 5-10

Java- Session: 5-10

8th - 10th Grade

10 Qs

Java Test 1

Java Test 1

Assessment

Quiz

Computers

10th Grade

Medium

Created by

Vikas Bandaru

Used 5+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare an instance variable in Java?
public static int myVariable;
static public int myVariable;
int myVariable;
protected int myVariable;

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a constructor in Java?
To define a variable
To create a new class
To call a method
To initialize instance variables

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between a class and an object in Java?
A class is a blueprint for an object, while an object is an instance of a class.
A class is a data type, while an object is a variable.
A class contains variables and methods, while an object contains only variables.
A class can have multiple instances, while an object is a single instance of a class.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to define a setter method in Java?
public void setMyVariable();
public setMyVariable(int value);
public void setMyVariable(int value) { myVariable = value; }
All of the above

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct syntax for a single-line comment in Java?
/*This is a comment*/
This is a comment//
// This is a comment
# This is a comment

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a getter method in Java?
To get the value of a variable
To set the value of a variable
To create a new object
All of the above

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare a class in Java?

public MyClass { // code block }

class public MyClass() { // code block }

public class MyClass { // code block }

None of the above

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?