wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java fundamentals starts with Git

Total questions: 86

Worksheet time: 44mins

Name
Class
Date
1.

Which of the following can be operands of arithmetic operators?

a)

Numeric

b)

Boolean

c)

Both Numeric & Characters

d)

Characters

2.

What will be the output of the following Java program?

class Output {

public static void main(String args[]) {

int a = 1;

int b = 2;

int c;

int d;

c = ++b;

d = a++;

c++;

b++;

++a;

System.out.println(a + " " + b + " " + c); }

}

a)

3 2 4

b)

3 2 3

c)

2 3 4

d)

2 4 4

e)

3 4 4

3.

Which of these can be returned by the operator &?

a)

Integer

b)

Boolean

c)

Integer or Boolean

d)

Character

4.

What will be the output of the following Java program?

class comma_operator {

public static void main(String args[]) {

int sum = 0;

for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)

sum += i;

System.out.println(sum); }

}

a)

5

b)

4

c)

6

d)

14

5.

Which of these can not be used for a variable name in Java?

a)

identifier

b)

identifier & keyword

c)

keyword

d)

none of the mentioned

6.

What will be the output of the following Java code?

class operators {

public static void main(String args[]) {

int x = 8;

System.out.println(++x * 3 + " " + x); }

}

a)

24 8

b)

24 9

c)

27 9

d)

27 8

7.

Which of the following is not an operator in Java?

a)

instanceof

b)

sizeof

c)

>>>=

d)

new

8.

What will be the output of the following Java program?

class jump_statments {

public static void main(String args[]) {

int x = 2;

int y = 0;

for ( ; y < 10; ++y) {

if (y % x == 0)

continue;

else if (y == 8)

break;

else

System.out.print(y + " "); }

}

}

a)

1 3 5 7

b)

2 4 6 8

c)

1 3 5 7 9

d)

1 2 3 4 5 6 7 8 9

9.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

while

b)

do-while

c)

for

d)

none of the mentioned

10.

What will be the output of the following Java code?

class Relational_operator {

public static void main(String args[]) {

int var1 = 5;

int var2 = 6;

System.out.print(var1 > var2); }

}

a)

5

b)

6

c)

true

d)

false

11.

Which of these is not a bitwise operator?

a)

&

b)

&=

c)

|=

d)

<=

12.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double

13.

Command Line Arguments are passed to ----

a)

Variable

b)

String

c)

String[ ] args

d)

class

14.

int x=4;

int y=6;

int res=(x>y)?x:y;

find the value of res?

a)

4

b)

6

c)

1

d)

0

15.

int a;

byte b=45;   

a=b;

the type conversion is...........

a)

manual

b)

explicit

c)

error

d)

implicit

16.

An integer array of 10 cells is declared as.................

a)

int a[ ]

b)

int[ ]=a

c)

a=new int[10]

d)

int[5][5] a =new int[10]

17.

The size of float data type in bits is______

a)

4

b)

32

c)

2

d)

16

18.

Identify the unary operator among the following.............

a)

a++;

b)

a=b+c;

c)

a=b>c;

d)

a=(b==c)

19.

x=10;

y=15;

d=(--x)+(--y);

a)

25

b)

23

c)

24

d)

26

20.

boolean a=false;

boolean b=true;

boolean c=(a&&b);

find out the value of c ............

a)

True

b)

Error

c)

False

d)

1

21.

int x=7,y=9;

int z=x&y;

find the value of z ........

a)

4

b)

0

c)

1

d)

9

22.

Which of the following option leads to the portability and security of Java?

a)

Bytecode is executed by JVM

b)

The applet makes the Java code secure and portable

c)

Use of exception handling

d)

Dynamic binding between objects

23.

Which of the following is not a Java features?

a)

Dynamic

b)

Architecture Neutral

c)

Use of pointers

d)

Object-oriented

24.

_____ is used to find and fix bugs in the Java programs.

a)

JVM

b)

JRE

c)

JDK

d)

JDB

25.

Which of the following is a valid declaration of a char?

a)

char ch = '\utea';

b)

char ca = 'tea';

c)

char cr = '\u0223';

d)

char cc = '\itea';

26.

What does the expression float a = 35 / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

27.

What does the expression int a = 35 / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

28.

What does the expression float a = 35.0f / 0 return?

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

29.

Evaluate the following Java expression, if x=3, y=5, and z=10:

++z + y - y + z + x++

a)

24

b)

23

c)

20

d)

25

30.

Which of the following for loop declaration is not valid?

a)

for ( int i = 99; i >= 0; i / 9 )

b)

for ( int i = 7; i <= 77; i += 7 )

c)

for ( int i = 20; i >= 2; - -i )

d)

for ( int i = 2; i <= 20; i = 2* i )

31.

Which of the following is not OOPS concept in Java?

a)

Inheritance

b)

Encapsulation

c)

Polymorphism

d)

Compilation

32.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

33.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

34.

Which concept of Java is a way of converting real world objects in terms of class?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Inheritance

35.

Which concept of Java is achieved by combining methods and attribute into a class?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

36.

Which component is used to compile, debug and execute java program?

a)

JVM

b)

JDK

c)

JIT

d)

JRE

37.

Which of the below is invalid identifier with the main method?

a)

public

b)

static

c)

final

d)

private

38.

What is use of interpreter?

a)

They convert bytecode to machine language code

b)

They read high level code and execute them

c)

They are intermediated between JIT and JVM

d)

It is a synonym for JIT

39.

What is the extension of compiled java classes?

a)

.java

b)

.class

c)

.txt

d)

.js

40.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

41.

Which of these statement is incorrect?

a)

Every class must contain a main() method

b)

Applets do not require a main() method at all

c)

There is at-least one main() method in a program

d)

main() method must be made public

42.

Which of the following statements is correct?

a)

Public method is accessible to all other classes in the hierarchy

b)

Public method is accessible only to subclasses of its parent class

c)

Public method can only be called by object of its class

d)

Public method can be accessed by calling object of the public class

43.

Which of this keyword must be used to inherit a class?

a)

super

b)

this

c)

extend

d)

extends

44.

Which of the following statements is correct?

a)

Public method is accessible to all other classes in the hierarchy

b)

Public method is accessible only to subclasses of its parent class

c)

Public method can only be called by object of its class

d)

Public method can be accessed by calling object of the public class

45.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

46.

Is Android based on Java?

a)

True

b)

False

47.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

48.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

49.

When saving a Java source file, save it with an extension of

a)

.java.

b)

.javac.

c)

.src.

d)

.class.

50.

To print "Hello, world" on the monitor, use the following Java statement:

a)

System.out.println("Hello, world");

b)

System Print = "Hello, world";

c)

SystemOutPrintln('Hello, world');

d)

system.out.println{Hello, world};

51.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

52.

What is a local copy of a remote repository called?

a)

Branch

b)

Origin

c)

Clone

d)

Master

53.

The main objectives of Git are :

a)

speed

b)

data integrity

c)

support for distributed non-linear workflows

d)

All of the above

54.

Git command . . . . used to give tags to the specified commit.

a)

git checkout [branch name]

b)

git show [commit]

c)

git tag [commitID]

d)

git rm [file]

55.

Git is a . . . . Version Control tool.

a)

Decentralized

b)

Centralized

56.

Which of the following command line environment is used for interacting with Git ?

a)

Git Bash

b)

GitHub

c)

Git Boot

d)

Git Lab

57.

____ removes untracked files from your working directory.

a)

git commit

b)

git clean -f

c)

git clean

d)

git reset

58.

Which command creates an empty Git repository in the specified directory?

a)

git reset

b)

git log ..

c)

git init

d)

git init --bare

59.

Git command to compare two specified branches

a)

git diff

b)

git merge

c)

git blame -L

d)

git push --tags

60.

1. Which of these terms best describes GitHub?

a)

Issue Tracking System

b)

Web-Based Repository Hosting Service

c)

Distributed Version Control System

d)

Integrated Development Environment

61.

2. Which command should you use to initialize a new git repository?

a)

Git install

b)

Git bash

c)

Git start

d)

Git init

62.

3. What is the opposite of git clone?

a)

Git push

b)

Git status

c)

Git add

d)

Git upload

63.

4. How do you check the state of your local git repository since your last commit?

a)

Git commit

b)

Git status

c)

Git check

d)

Git diff

64.

5. How do you supply a commit message to a commit?

a)

Git message "I'm coding!"

b)

Git commit "I'm coding!"

c)

Git commit -m "I'm coding!"

d)

Git add "I'm coding!"

65.

6. What's the git command that downloads your repository from GitHub to your computer?

a)

Git fork

b)

Git commit

c)

Git clone

d)

Git push

66.

7. Which is the correct usage of push command?

a)

Git push <branch> <remote>

b)

Git push <remote> <branch>

c)

Both correct

d)

None of them

67.

8. Which is the correct order to submit your changes from the working directory all the way to the remote repository?

a)

Git add, git commit, git push

b)

Git push, git add, git commit

c)

Git add, git push, git commit

d)

Git commit, git add, git push

68.

9. To get the lastest changes from your remote repository, the git command is?

a)

Git pull down

b)

Git reset

c)

Git refresh

d)

Git pull origin master

69.

10. After you initialize a new git repository and create a file named git-quiz.html, which of the following commands will not work if issued?

a)

Git add git-quiz.html

b)

Git commit -m "git quiz web file added"

c)

Git add

d)

Git status

70.

What is Git primarily used for?

a)

Project management tool for teams

b)

Version control system for tracking changes in code.

c)

Database management system

d)

Cloud storage solution for files

71.

Explain the purpose of a branch in Git.

a)

Branches allow multiple users to work on the same file simultaneously without conflicts.

b)

Branches are primarily for organizing files in a Git repository.

c)

Branches are used to permanently delete code in Git.

d)

The purpose of a branch in Git is to enable isolated development for features, fixes, or experiments without impacting the main codebase.

72.

What command is used to create a new branch?

a)

git branch

b)

git checkout -b

c)

git create branch

d)

git new-branch

73.

How do you merge a branch into the main branch?

a)

Execute 'git pull ' to merge changes.

b)

Run 'git rebase ' on the main branch.

c)

Use 'git checkout ' to switch branches.

d)

Use 'git merge ' after checking out the main branch.

74.

What is a commit in Git?

a)

A commit in Git is a way to merge two repositories.

b)

A commit in Git is a snapshot of changes in a repository.

c)

A commit in Git is a type of branch.

d)

A commit in Git is a command to delete files.

75.

How can you view the commit history in Git?

a)

Run 'git status' to see commit history.

b)

Use the command 'git log'.

c)

Use the command 'git history'.

d)

View the commit history in the settings menu.

76.

What does a pull request do in GitHub?

a)

A pull request allows developers to propose changes, review code, and merge updates in a collaborative manner.

b)

A pull request automatically merges changes without review.

c)

A pull request is used to delete files from a repository.

d)

A pull request is a way to create a new branch in GitHub.

77.

What is the difference between a fork and a branch?

a)

A fork is used for collaboration; a branch is used for merging.

b)

A fork is a copy of a repository for independent development; a branch is a parallel version within the same repository.

c)

A fork is a temporary change; a branch is a permanent change.

d)

A fork is a version of a branch; a branch is a copy of a repository.

78.

How can you resolve a merge conflict?

a)

Identify conflicting files, resolve conflicts, remove markers, stage, and commit.

b)

Delete the conflicting files

c)

Revert to the previous commit without resolving conflicts

d)

Ignore the conflict and continue merging

79.

What is the significance of the .gitignore file?

a)

The .gitignore file prevents specified files from being tracked by Git.

b)

The .gitignore file is used to track all files in a repository.

c)

The .gitignore file is a command that initializes a Git repository.

d)

The .gitignore file is for storing commit messages.

80.

Which command is used to initialize a new Git repository?

a)

git start

b)

git init

c)

git create

d)

git new

81.

What does the 'git clone' command do?

a)

Create a new branch

b)

Clone a repository from a remote server

c)

Create a copy of the local repository

d)

Move the repository to a new location

82.

How do you revert the last commit in Git?

a)

git undo

b)

git revert HEAD

c)

git reset --hard HEAD

d)

git revert --last

83.

What does the command 'git stash' do?

a)

Remove changes from the staging area

b)

Save changes that are not ready to be committed yet

c)

Delete the working directory

d)

Revert the last commit

84.

What is the purpose of the 'git rebase' command?

a)

Create a new branch

b)

Move or combine a sequence of commits to a new base commit

c)

Rename a branch

d)

Undo the last commit

85.

Which command is used to create a new repository on GitHub from the command line?

a)

git init

b)

git create

c)

git new

d)

None of the above

86.

A special file that is used in Git to tell which files and directories to ignore when making a commit.

a)

.gitignore

b)

ignore-files

c)

.ignore

d)

config