0% found this document useful (0 votes)
29 views

Quiz About Java Data Types

Uploaded by

mostafa nasser
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Quiz About Java Data Types

Uploaded by

mostafa nasser
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DSA

Data Science Sign In


Web Tech
Courses
Trending Now Data Structures Algorithms System Design Foundational Courses Data Science Practice Problem Python Machine L

Java Data Types Trending in News View More

105 Funny Things to Do to Make


Question 1 Someone Laugh
Best PS5 SSDs in 2024: Top Picks
for Expanding Your Storage
Best Nintendo Switch Controllers
C in 2024
#geekstreak2024 – 21 Days POTD
class Main {
Challenge Powered By Deutsche
public static void main(String args[]) { Bank
int t; Full Stack Developer Roadmap
System.out.println(t);
[2024 Updated]
}
}

garbage value

compiler error

runtime error

Discuss it

Question 1 ‒ Explanation
Unlike class members, local variables of methods must be assigne
d a value to before they are accessed, or it is a compile error.

Question 2

Predict the output of following Java program.

class Test {
public static void main(String[] args) {
for(int i = 0; 0; i++)
{
System.out.println("Hello");
break;
}
}
}
Hello

Empty Output

Compiler error

Runtime error

Discuss it

Question 2 ‒ Explanation
The error is in for loop where 0 is used in place of boolean value.
Unlike C++, use of non boolean variables in place of bool is not all
owed

Question 3

Predict the output of the following program.

Java

class Test
{
public static void main(String[] args)
{
Double object = new Double("2.4");
int a = object.intValue();
byte b = object.byteValue();
float d = object.floatValue();
double c = object.doubleValue();

System.out.println(a + b + c + d );

}
}

8.8

8.800000095367432

Discuss it

Question 3 ‒ Explanation
Arithmetic conversions are implicitly performed to cast the values
to a common type. The compiler first performs integer promotion.
If the operands still have different types, then they are converted t
o the type that appears highest in the hierarchy.
Question 4

Which of the following statements is/are TRUE regarding JAVA ? (a)


Constants that cannot be changed are declared using the ‘static’
keyword. (b) A class can only inherit one class but can implement
multiple interfaces.

Only (a) is TRUE.

Only (b) is TRUE.

Both (a) and (b) are TRUE.

Neither (a) nor (b) are TRUE.

Discuss it

Question 4 ‒ Explanation
In JAVA, constant are not declared using \'static\' keyword and a cl
ass can implement multiple interfaces but class can inherit one cla
ss only. So, option (B) is correct.

You have completed 4/4 questions .


Your accuracy is 25%.

Last Updated : Mar 22, 2024

Take a part in the ongoing discussion View All Discussion


Company Languages DSA Data Web Python
About Us Python Data Science & Technologies Tutorial
Corporate & Legal Java Structures
Communications Address:- In Media
ML HTML Python
C++ Algorithms CSS Programming
A-143, 9th Floor, Sovereign Data Science
Corporate Tower, Sector- Contact Us PHP DSA for JavaScript Examples
With Python
136, Noida, Uttar Pradesh Advertise with GoLang Beginners TypeScript Python Projects
(201305) | Registered Data Science
us SQL Basic DSA ReactJS Python Tkinter
Address:- K 061, Tower K, For Beginner
GFG Corporate R Language Problems NextJS Web Scraping
Gulshan Vivante Apartment, Solution
Machine
Sector 137, Noida, Gautam Android DSA Bootstrap OpenCV Tutorial
Learning
Buddh Nagar, Uttar Pradesh, Placement Tutorial Roadmap Web Design Python Interview
ML Maths
201305 Training Tutorials Top 100 Question
Data
Program Archive DSA Django
Visualisation
GeeksforGeeks Interview
Pandas
Community Problems
NumPy
DSA
NLP
Roadmap
Deep Learning
by
Sandeep
Jain
All Cheat
Sheets

Computer DevOps System Inteview School GeeksforGeeks


Science Git Design Preparation Subjects Videos
Operating Linux High Level Competitive Mathematics DSA
Systems AWS Design Programming Physics Python
Computer Docker Low Level Top DS or Algo Chemistry Java
Network Kubernetes Design for CP Biology C++
Database Azure UML Company-Wise Social Science Web Development
Management GCP Diagrams Recruitment English Data Science
System DevOps Interview Process Grammar CS Subjects
Software Roadmap Guide Company-Wise Commerce
Engineering Design Preparation World GK
Digital Logic Patterns Aptitude
Design OOAD Preparation
Engineering System Puzzles
Maths Design
Software Bootcamp
Development Interview
Software Questions
Testing

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

You might also like