Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6173455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:34:47+00:00 2026-05-23T23:34:47+00:00

I am a Java developer trying to learn Class creation in Scala. I create

  • 0

I am a Java developer trying to learn Class creation in Scala.

I create two separate scala files.
One file contains a trait. The second file extends the trait and defines a method.

Cola.scala This contains the trait.

trait Cola
{
        def fizz(): String
}

Pepsi.scala This has a class that tries to extend the trait.

class Pepsi extends Cola
{
        override def fizz():String = "1 Sugar"
}

var p = new Pepsi
println( " p = " + p.fizz )

When I excecute “scala Pepsi.scala” I get the following error message:

 error: not found: type Cola
class Pepsi extends Cola

Both files are in the same folder.

Please help how to resolve this?
I am using Scala 2.8
I am not using an editor so that I will be forced from scratch. This is to improve my knowledge about computers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:34:47+00:00Added an answer on May 23, 2026 at 11:34 pm

    Scala doesn’t require you to put all of your traits and classes into eponymous (that is, named the same as the class) files. You can simply put all of that in one file and it will work. Or you can specify both files on the command line: Scala will not automatically look for Cola in Cola.scala.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a Java developer looking to learn some C#/ASP.NET. One thing I've never liked
I am a Java developer trying to learn C++. I have many times read
I am an experienced Java developer who is trying to learn web development with
I am an usual Java developer but now I'm trying to create some OpenGL
I am a C#/Java developer trying to learn C++. As I try to learn
I'm a long time C++/Java developer trying to get into Python and am looking
Ages ago when I was a java developer I could make separate ant scripts
What books would you guys recommend if one has been a java developer for
I wonder why would a C++, C#, Java developer want to learn a dynamic
I've developed in Java in the past, and now I'm trying to learn Grails/Groovy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.