Font size
WorksheetsJava fundamentals starts with Git
Total questions: 86
Worksheet time: 44mins
Which of the following can be operands of arithmetic operators?
Numeric
Boolean
Both Numeric & Characters
Characters
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); }
}
3 2 4
3 2 3
2 3 4
2 4 4
3 4 4
Which of these can be returned by the operator &?
Integer
Boolean
Integer or Boolean
Character
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); }
}
5
4
6
14
Which of these can not be used for a variable name in Java?
identifier
identifier & keyword
keyword
none of the mentioned
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); }
}
24 8
24 9
27 9
27 8
Which of the following is not an operator in Java?
instanceof
sizeof
>>>=
new
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 + " "); }
}
}
1 3 5 7
2 4 6 8
1 3 5 7 9
1 2 3 4 5 6 7 8 9
Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
while
do-while
for
none of the mentioned
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); }
}
5
6
true
false
Which of these is not a bitwise operator?
&
&=
|=
<=
What is the output of relational operators?
Integer
Boolean
Characters
Double
Command Line Arguments are passed to ----
Variable
String
String[ ] args
class
int x=4;
int y=6;
int res=(x>y)?x:y;
find the value of res?
4
6
1
0
int a;
byte b=45;
a=b;
the type conversion is...........
manual
explicit
error
implicit
An integer array of 10 cells is declared as.................
int a[ ]
int[ ]=a
a=new int[10]
int[5][5] a =new int[10]
The size of float data type in bits is______
4
32
2
16
Identify the unary operator among the following.............
a++;
a=b+c;
a=b>c;
a=(b==c)
x=10;
y=15;
d=(--x)+(--y);
25
23
24
26
boolean a=false;
boolean b=true;
boolean c=(a&&b);
find out the value of c ............
True
Error
False
1
int x=7,y=9;
int z=x&y;
find the value of z ........
4
0
1
9
Which of the following option leads to the portability and security of Java?
Bytecode is executed by JVM
The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
Which of the following is not a Java features?
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
_____ is used to find and fix bugs in the Java programs.
JVM
JRE
JDK
JDB
Which of the following is a valid declaration of a char?
char ch = '\utea';
char ca = 'tea';
char cr = '\u0223';
char cc = '\itea';
What does the expression float a = 35 / 0 return?
0
Not a number
Infinity
Run time exception
What does the expression int a = 35 / 0 return?
0
Not a number
Infinity
Run time exception
What does the expression float a = 35.0f / 0 return?
0
Not a number
Infinity
Run time exception
Evaluate the following Java expression, if x=3, y=5, and z=10:
++z + y - y + z + x++
24
23
20
25
Which of the following for loop declaration is not valid?
for ( int i = 99; i >= 0; i / 9 )
for ( int i = 7; i <= 77; i += 7 )
for ( int i = 20; i >= 2; - -i )
for ( int i = 2; i <= 20; i = 2* i )
Which of the following is not OOPS concept in Java?
Inheritance
Encapsulation
Polymorphism
Compilation
Which of the following is a type of polymorphism in Java?
Compile time polymorphism
Execution time polymorphism
Multiple polymorphism
Multilevel polymorphism
When does method overloading is determined?
At run time
At compile time
At coding time
At execution time
Which concept of Java is a way of converting real world objects in terms of class?
Polymorphism
Encapsulation
Abstraction
Inheritance
Which concept of Java is achieved by combining methods and attribute into a class?
Encapsulation
Inheritance
Polymorphism
Abstraction
Which component is used to compile, debug and execute java program?
JVM
JDK
JIT
JRE
Which of the below is invalid identifier with the main method?
public
static
final
private
What is use of interpreter?
They convert bytecode to machine language code
They read high level code and execute them
They are intermediated between JIT and JVM
It is a synonym for JIT
What is the extension of compiled java classes?
.java
.class
.txt
.js
Which of these keywords is used to make a class?
class
struct
int
none of the mentioned
Which of these statement is incorrect?
Every class must contain a main() method
Applets do not require a main() method at all
There is at-least one main() method in a program
main() method must be made public
Which of the following statements is correct?
Public method is accessible to all other classes in the hierarchy
Public method is accessible only to subclasses of its parent class
Public method can only be called by object of its class
Public method can be accessed by calling object of the public class
Which of this keyword must be used to inherit a class?
super
this
extend
extends
Which of the following statements is correct?
Public method is accessible to all other classes in the hierarchy
Public method is accessible only to subclasses of its parent class
Public method can only be called by object of its class
Public method can be accessed by calling object of the public class
Java was originally named:
Coffee
Oak
New C++
Duke
Is Android based on Java?
True
False
Who invented Java?
James Gosling
Sergey Brin
Steve Jobs
Bill Gates
Tim Berners-Lee
Which company owns Java?
Oracle
Microsoft
Apple
Intel
When saving a Java source file, save it with an extension of
.java.
.javac.
.src.
.class.
To print "Hello, world" on the monitor, use the following Java statement:
System.out.println("Hello, world");
System Print = "Hello, world";
SystemOutPrintln('Hello, world');
system.out.println{Hello, world};
Where does a java program start executing instructions from:
class
source file
main method
object
What is a local copy of a remote repository called?
Branch
Origin
Clone
Master
The main objectives of Git are :
speed
data integrity
support for distributed non-linear workflows
All of the above
Git command . . . . used to give tags to the specified commit.
git checkout [branch name]
git show [commit]
git tag [commitID]
git rm [file]
Git is a . . . . Version Control tool.
Decentralized
Centralized
Which of the following command line environment is used for interacting with Git ?
Git Bash
GitHub
Git Boot
Git Lab
____ removes untracked files from your working directory.
git commit
git clean -f
git clean
git reset
Which command creates an empty Git repository in the specified directory?
git reset
git log ..
git init
git init --bare
Git command to compare two specified branches
git diff
git merge
git blame -L
git push --tags
1. Which of these terms best describes GitHub?
Issue Tracking System
Web-Based Repository Hosting Service
Distributed Version Control System
Integrated Development Environment
2. Which command should you use to initialize a new git repository?
Git install
Git bash
Git start
Git init
3. What is the opposite of git clone?
Git push
Git status
Git add
Git upload
4. How do you check the state of your local git repository since your last commit?
Git commit
Git status
Git check
Git diff
5. How do you supply a commit message to a commit?
Git message "I'm coding!"
Git commit "I'm coding!"
Git commit -m "I'm coding!"
Git add "I'm coding!"
6. What's the git command that downloads your repository from GitHub to your computer?
Git fork
Git commit
Git clone
Git push
7. Which is the correct usage of push command?
Git push <branch> <remote>
Git push <remote> <branch>
Both correct
None of them
8. Which is the correct order to submit your changes from the working directory all the way to the remote repository?
Git add, git commit, git push
Git push, git add, git commit
Git add, git push, git commit
Git commit, git add, git push
9. To get the lastest changes from your remote repository, the git command is?
Git pull down
Git reset
Git refresh
Git pull origin master
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?
Git add git-quiz.html
Git commit -m "git quiz web file added"
Git add
Git status
What is Git primarily used for?
Project management tool for teams
Version control system for tracking changes in code.
Database management system
Cloud storage solution for files
Explain the purpose of a branch in Git.
Branches allow multiple users to work on the same file simultaneously without conflicts.
Branches are primarily for organizing files in a Git repository.
Branches are used to permanently delete code in Git.
The purpose of a branch in Git is to enable isolated development for features, fixes, or experiments without impacting the main codebase.
What command is used to create a new branch?
git branch
git checkout -b
git create branch
git new-branch
How do you merge a branch into the main branch?
Execute 'git pull
Run 'git rebase
Use 'git checkout
Use 'git merge
What is a commit in Git?
A commit in Git is a way to merge two repositories.
A commit in Git is a snapshot of changes in a repository.
A commit in Git is a type of branch.
A commit in Git is a command to delete files.
How can you view the commit history in Git?
Run 'git status' to see commit history.
Use the command 'git log'.
Use the command 'git history'.
View the commit history in the settings menu.
What does a pull request do in GitHub?
A pull request allows developers to propose changes, review code, and merge updates in a collaborative manner.
A pull request automatically merges changes without review.
A pull request is used to delete files from a repository.
A pull request is a way to create a new branch in GitHub.
What is the difference between a fork and a branch?
A fork is used for collaboration; a branch is used for merging.
A fork is a copy of a repository for independent development; a branch is a parallel version within the same repository.
A fork is a temporary change; a branch is a permanent change.
A fork is a version of a branch; a branch is a copy of a repository.
How can you resolve a merge conflict?
Identify conflicting files, resolve conflicts, remove markers, stage, and commit.
Delete the conflicting files
Revert to the previous commit without resolving conflicts
Ignore the conflict and continue merging
What is the significance of the .gitignore file?
The .gitignore file prevents specified files from being tracked by Git.
The .gitignore file is used to track all files in a repository.
The .gitignore file is a command that initializes a Git repository.
The .gitignore file is for storing commit messages.
Which command is used to initialize a new Git repository?
git start
git init
git create
git new
What does the 'git clone' command do?
Create a new branch
Clone a repository from a remote server
Create a copy of the local repository
Move the repository to a new location
How do you revert the last commit in Git?
git undo
git revert HEAD
git reset --hard HEAD
git revert --last
What does the command 'git stash' do?
Remove changes from the staging area
Save changes that are not ready to be committed yet
Delete the working directory
Revert the last commit
What is the purpose of the 'git rebase' command?
Create a new branch
Move or combine a sequence of commits to a new base commit
Rename a branch
Undo the last commit
Which command is used to create a new repository on GitHub from the command line?
git init
git create
git new
None of the above
A special file that is used in Git to tell which files and directories to ignore when making a commit.
.gitignore
ignore-files
.ignore
config
