Java Test 1

Java Test 1

10th Grade

15 Qs

quiz-placeholder

Similar activities

Computer Science: Chapter 1 Test Review

Computer Science: Chapter 1 Test Review

9th - 12th Grade

20 Qs

CWA Java

CWA Java

10th - 12th Grade

13 Qs

QUIZ-I-OBJECT ORIENTED PROGRAMMING WITH C++

QUIZ-I-OBJECT ORIENTED PROGRAMMING WITH C++

10th Grade - University

10 Qs

java

java

10th Grade

15 Qs

Python Classes Quiz

Python Classes Quiz

9th - 12th Grade

15 Qs

Java OOP Connections

Java OOP Connections

10th - 12th Grade

20 Qs

CSA 1.1.1 Why Programming? Why Java?

CSA 1.1.1 Why Programming? Why Java?

10th - 12th Grade

14 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?