Prabal Nandy

Greenhorn
+ Follow
since Oct 16, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Prabal Nandy

Thank you Paul and Piet!
I came to know the fact later.
Hello Everyone,

Could anyone please look into the code below?



The is compiling and the output is 10.

My Question: Can we create an instance of an interface which has a default method?
e.g:
Jumpable tc = new Jumpable(){};

Thanks,
Prabal.

Prabal Nandy wrote:Thanks Paul and Ganesh.
The editor was using JDK 6.

Thanks Paul and Ganesh.
The editor was was using JDK 6.
Hi, Please check the code snippet below:


This Code compiles in cmd prompt  but does not compile in Editor.
Showing error at line 4: incompatible types firstName. A type reference is not allowed.

Please suggest!

Thanks.
I don't have CLASSPATH set in my environment variables.
Basically this command worked for me:
D:\src\view>java -cp .. view.Sort

Since my java file was under view package I needed to specify the fully qualified class name (view.Sort) and since my java and class file location was same (under view folder) I needed to use ".." as the class path to go back to src folder to mention fully qualified class name.
It compiled and class file was generated.
However while running it showed the error.
Error: Could not find or load main class Sort

I set the classpath also but still showing the same error.
Thank You Paul!
You are right. However after compiling the line I was not able to execute it. Not sure why.

D:\src>javac Sort.java

D:\src>java Sort
Error: Could not find or load main class Sort


Code block:
-----------

public class Sort
{
public static void main( String[] args )
{
   long t = 1923013981938103232L;  // DOES NOT COMPILE
}
}

Thanks,
Prabal.
Thanks for your quick response.
It is compiling successfully.
However I am getting error at run-time.
Error(12,22):  integer number too large: 1923013981938103232.

I think here the fact is: By default the value is considered as an int literal and we can assign an int into a long literal (since long type has a higher range than a int type, the int will be converted to long at compile time). However at run-time it will check the range and show the error.

Please advice!
Hi,

I have a question regarding Casting Primitive Values.

In the book OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 >
Chapter 2: Operators and Statements > Using Additional Binary Operators:

I got this: long t = 192301398193810323;  // DOES NOT COMPILE

It says it does not compile.
But in the editor when I tried it compiled.

Please suggest.

Here is the online book URL:
http://techbus.safaribooksonline.com/book/certification/oracle/9781118957424/chapter-2-operators-and-statements/c02_level1_2_html

Thanks,
Prabal.